473,659 Members | 3,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

any reason why PHP upload script would work on PC but not Mac?

The following upload script seems to be working on PCs but not on
Macs. Can anyone imagine a reason why? Could there be something in the
form that turns in flawed data, or could IE on a Mac not pass along
certain data that Netscape and IE do on a PC?


function standardImageUp load() {
$controllerForA ll = & getController() ;
$insertObject = & $controllerForA ll->getObject("McT ransactions", " in
standardImageUp load().");
$formatTextObje ct = & $controllerForA ll->getObject("McF ormatText", "
in standardImageUp load().");
$resultsObject = & $controllerForA ll->getObject("McR esults", " in
standardImageUp load().");

$config = getConfig();
$pathToImageFol der = $config["pathToImageFol der"];
$imagesFolder = $config["imagesFold er"];

global $uploadedFile, $uploadedFile_s ize, $uploadedFile_n ame;

if (!$uploadedFile ) {
$uploadedFile = $controllerForA ll->getVar("$uploa dedFile");
$uploadedFile_s ize =
$controllerForA ll->getVar("$uploa dedFile_size");
$uploadedFile_s ize =
$controllerForA ll->getVar("$uploa dedFile_size");
}
$uploadedFile_n ame =
$formatTextObje ct->processFileNam e($uploadedFile _name);
$uploadedFile_n ame = htmlspecialchar s($uploadedFile _name);
// 04-20-04 - we need to keep hackers from uploading files with PHP,
or if they do, we need to keep those files
// from being sent to the PHP parser. So we look for typical PHP
extensions.
$fileSafe = true;
$ext = substr($uploade dFile_name, -4);
if ($ext == "php3") $fileSafe = false;
if ($ext == ".php") $fileSafe = false;
if ($ext == ".inc") $fileSafe = false;
if ($ext == "phtm") $fileSafe = false;

$ext = substr($uploade dFile_name, -5);
if ($ext == "phtml") $fileSafe = false;
if ($fileSafe) {
$absolutePath .= $pathToImageFol der.$uploadedFi le_name;
$urlPath .= $imagesFolder.$ uploadedFile_na me;

if (is_dir($pathTo ImageFolder)) {
if (!file_exists($ absolutePath)) {
if (copy($uploaded File, $absolutePath)) {
$resultsObject->addToResults(" Success: The image or file
'$uploadedFile_ name' has been uploaded. If you wish to reference it
this is the address: <a href='$urlPath' >$uploadedFile_ name</a>");
} else {
if ($uploadedFile_ size > 2000000) {
$resultsObject->addToResults(" Error: the upload failed. Your
file of '$uploadedFile_ name' is not uploaded. It is very large, with a
size of $uploadedFile_s ize. This may have been a factor in its
failure.");
} else {
$resultsObject->addToResults(" Error: the upload failed. Your
file of '$uploadedFile_ name' is not uploaded.");
}
}
} else {
$resultsObject->addToResults(" Error: a file with the same name as
the one you are uploading already exists. Please delete the old file
first, and then upload the new one.");
}
} else {
$resultsObject->error("We tried to copy the image to the image
folder that is specified in your site's configuration, yet the folder
doesn't seem to be there.", "standardImageU pload");
}
$controllerForA ll->import("standa rdInsert", " in
standardImageUp load().");
standardInsert( );
} else {
$resultsObject->addToResults(" <b>Error:</b> Terribly sorry, but it
looks like you're trying to upload a PHP file. For security reasons,
this is not allowed. The extension on your file was '$ext'.");
}
}
Jul 17 '05 #1
2 2247
On 14 Jul 2004 23:15:51 -0700, lk******@geocit ies.com (lawrence)
wrote:
The following upload script seems to be working on PCs but not on
Macs. Can anyone imagine a reason why? Could there be something in the
form that turns in flawed data, or could IE on a Mac not pass along
certain data that Netscape and IE do on a PC?


the reason could be something in the form, but unfortunately I don't
see any <form> tag in your code ;-)

The most likely reason why forms do not work on some browsers is, that
you forgot to fill the "action" parameter in your form-tag correctly.
Some browsers (like IE on Windows) assume the same URL when this tag
is empty. But not all Browsers are so forgivable about that.

So it is obviously not a PHP problem, because PHP works regardless of
the browser type and OS because unlike JavaScript it runs on the
server, not in the browser.

Regards

Marian

--
Tipps und Tricks zu PHP, Coaching und Projektbetreuun g
http://www.heddesheimer.de/coaching/
Jul 17 '05 #2
Marian Heddesheimer <10************ *@spamgourmet.c om> wrote in message news:<hv******* *************** **********@4ax. com>...
On 14 Jul 2004 23:15:51 -0700, lk******@geocit ies.com (lawrence)
wrote:
The following upload script seems to be working on PCs but not on
Macs. Can anyone imagine a reason why? Could there be something in the
form that turns in flawed data, or could IE on a Mac not pass along
certain data that Netscape and IE do on a PC?


the reason could be something in the form, but unfortunately I don't
see any <form> tag in your code ;-)

The most likely reason why forms do not work on some browsers is, that
you forgot to fill the "action" parameter in your form-tag correctly.
Some browsers (like IE on Windows) assume the same URL when this tag
is empty. But not all Browsers are so forgivable about that.

So it is obviously not a PHP problem, because PHP works regardless of
the browser type and OS because unlike JavaScript it runs on the
server, not in the browser.

Regards

Marian


Below you can see the entire form. Do you see something here that
would throw a flaw on a Mac?


<form method="post" action="/emt/mcControlPanel. php"
enctype="multip art/form-data" class="mcForm">
<input id="inputId1" type="hidden"
name="formInput s[formSecurityRat ing]" value="associat e"
class="hiddenIn put">

<script language="javas cript">
function DoPreview()
{
var filename = document.forms[0].inputId1.value ;
var Img = new Image();
if (navigator.appN ame == "Netscape")
{
alert("Previews do not work in Netscape.");
}
else
{
Img.src = filename;
ppImg = Img.src;
alert("You're loading image" + ppImg);
document.images[0].src = Img.src;
}
}
</script>

<div class="formElem ent">

Upload an image:
<input type="file" name="uploadedF ile"><input type="hidden"
name="uploadTyp e" value="image" onchange="DoPre view();"></div>

<div class="formElem ent">
Type an easy to read name (as opposed to the file name) for this
image:
<div class="inputBox Title"><input id="inputId2" type="text"
name="formInput s[cbHeadline]" value="" class="textInpu t">
</div></div>

<div class="formElem ent">
Type a brief description:<br >
<textarea id="inputId3" name="formInput s[cbMainContent]"
class="textarea Input"></textarea>

</div>

<div class="formElem ent">
Assign a category:
<select id="publicpenFo rmInput4" name="formInput s[cbModifier25]">
<option value=""></option>
<option value="x#x#x#bl ankx#x#x#">No choice made</option>
<option value="oil">oil </option>
<option value="painting ">painting</option>

<option value="PREWRITE S">PREWRITES </option>
<option value="watercol or">watercolo r</option>
</select>

<br>
Assign a category:
<select id="publicpenFo rmInput5" name="formInput s[cbModifier26]">
<option value=""></option>
<option value="x#x#x#bl ankx#x#x#">No choice made</option>

<option value="oil">oil </option>
<option value="painting ">painting</option>
<option value="PREWRITE S">PREWRITES </option>
<option value="watercol or">watercolo r</option>
</select>

<br>
Assign a category:
<select id="publicpenFo rmInput6" name="formInput s[cbModifier27]">
<option value=""></option>
<option value="x#x#x#bl ankx#x#x#">No choice made</option>
<option value="oil">oil </option>
<option value="painting ">painting</option>
<option value="PREWRITE S">PREWRITES </option>

<option value="watercol or">watercolo r</option>
</select>

<br>
Assign a category:
<select id="publicpenFo rmInput7" name="formInput s[cbModifier28]">
<option value=""></option>
<option value="x#x#x#bl ankx#x#x#">No choice made</option>
<option value="oil">oil </option>

<option value="painting ">painting</option>
<option value="PREWRITE S">PREWRITES </option>
<option value="watercol or">watercolo r</option>
</select>

<br>
Assign a category:
<select id="publicpenFo rmInput8" name="formInput s[cbModifier29]">

<option value=""></option>
<option value="x#x#x#bl ankx#x#x#">No choice made</option>
<option value="oil">oil </option>
<option value="painting ">painting</option>
<option value="PREWRITE S">PREWRITES </option>
<option value="watercol or">watercolo r</option>

</select>

<br>
Assign a category:
<select id="publicpenFo rmInput9" name="formInput s[cbModifier30]">
<option value=""></option>
<option value="x#x#x#bl ankx#x#x#">No choice made</option>
<option value="oil">oil </option>
<option value="painting ">painting</option>

<option value="PREWRITE S">PREWRITES </option>
<option value="watercol or">watercolo r</option>
</select>


</div>
<input type="hidden" name="formInput s[cbWhichType]" value="imageInf o">

<input type="hidden" name="choiceMad e" value="standard ImageUpload">
<input type="hidden" name="actions[choiceMade]"
value="standard ImageUpload">
<input type="hidden" name="fileName" value="">
<input type="submit" value="Click here when done" class="submitIn put">
</form>
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3016
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The welcome page has a browse button (for locating your local file), a textfield where the path is displayed, and a upload button. When clicking upload a VB ASP script is run, and the outcome is displayed on a new page. 1. On my local machine I got the...
15
5336
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
9
3824
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
7
3182
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
6
3324
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
I have a strange problem when uploading a PDF document to a web-server. When I try this to a web-server running Apache 2 on a FC 4, it fails. Firefox says that the document contain no data. If I upload it to a different web-server running RH 7.3 (an internal test-webserver), it works OK. The PDF document is created by OpenOffice 2.0 from a MS Word document. I have also had it converted to PDF in MS Word that could create PDF documents....
9
3887
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they click "Upload Image" instead of the doctor/animal technician having to look for for dental x-ray...
3
2252
by: lister | last post by:
Hi, I am in the middle of writing an image upload script and am limiting the size of uploads via upload_max_filesize. This all seems to be working well, and if I try and upload a bigger file then I get an UPLOAD_ERR_INI_SIZE sat in $_FILES. All hunkey dorey. However, in my testing there are one or two large files that cause problems. PHP appears to abort the upload early as it should, but when
5
3278
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is _uploadedfiles_xxxx) (php must be allowed to move uploaded files to this folder' - uploadedfiles_xxxx. I typed <?php chmod ('_uploadedfiles_xxxx',640); ?> into notepad and saved it as php in the uploaded_xxxx folder, when I went to test it, the error...
12
2482
by: GuangXiN | last post by:
I want the file upload element disappear, instead of it, I place a text box and a button with my own css defination. but it doesn't work on IE7. What should I do now? <form action="upload.php" method="POST" enctype="multipart/form-data"> <p> <span>Select photo:</span> <input type="file" name="photo" style="display:none;"> <input type="text" name="photoUrl" class="s1" /> <input type="button" class="s2"...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.