473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 standardImageUpload() {
$controllerForAll = & getController();
$insertObject = & $controllerForAll->getObject("McTransactions", " in
standardImageUpload().");
$formatTextObject = & $controllerForAll->getObject("McFormatText", "
in standardImageUpload().");
$resultsObject = & $controllerForAll->getObject("McResults", " in
standardImageUpload().");

$config = getConfig();
$pathToImageFolder = $config["pathToImageFolder"];
$imagesFolder = $config["imagesFolder"];

global $uploadedFile, $uploadedFile_size, $uploadedFile_name;

if (!$uploadedFile) {
$uploadedFile = $controllerForAll->getVar("$uploadedFile");
$uploadedFile_size =
$controllerForAll->getVar("$uploadedFile_size");
$uploadedFile_size =
$controllerForAll->getVar("$uploadedFile_size");
}
$uploadedFile_name =
$formatTextObject->processFileName($uploadedFile_name);
$uploadedFile_name = htmlspecialchars($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($uploadedFile_name, -4);
if ($ext == "php3") $fileSafe = false;
if ($ext == ".php") $fileSafe = false;
if ($ext == ".inc") $fileSafe = false;
if ($ext == "phtm") $fileSafe = false;

$ext = substr($uploadedFile_name, -5);
if ($ext == "phtml") $fileSafe = false;
if ($fileSafe) {
$absolutePath .= $pathToImageFolder.$uploadedFile_name;
$urlPath .= $imagesFolder.$uploadedFile_name;

if (is_dir($pathToImageFolder)) {
if (!file_exists($absolutePath)) {
if (copy($uploadedFile, $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_size. 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.", "standardImageUpload");
}
$controllerForAll->import("standardInsert", " in
standardImageUpload().");
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 2235
On 14 Jul 2004 23:15:51 -0700, lk******@geocities.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 Projektbetreuung
http://www.heddesheimer.de/coaching/
Jul 17 '05 #2
Marian Heddesheimer <10*************@spamgourmet.com> wrote in message news:<hv********************************@4ax.com>. ..
On 14 Jul 2004 23:15:51 -0700, lk******@geocities.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="multipart/form-data" class="mcForm">
<input id="inputId1" type="hidden"
name="formInputs[formSecurityRating]" value="associate"
class="hiddenInput">

<script language="javascript">
function DoPreview()
{
var filename = document.forms[0].inputId1.value;
var Img = new Image();
if (navigator.appName == "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="formElement">

Upload an image:
<input type="file" name="uploadedFile"><input type="hidden"
name="uploadType" value="image" onchange="DoPreview();"></div>

<div class="formElement">
Type an easy to read name (as opposed to the file name) for this
image:
<div class="inputBoxTitle"><input id="inputId2" type="text"
name="formInputs[cbHeadline]" value="" class="textInput">
</div></div>

<div class="formElement">
Type a brief description:<br>
<textarea id="inputId3" name="formInputs[cbMainContent]"
class="textareaInput"></textarea>

</div>

<div class="formElement">
Assign a category:
<select id="publicpenFormInput4" name="formInputs[cbModifier25]">
<option value=""></option>
<option value="x#x#x#blankx#x#x#">No choice made</option>
<option value="oil">oil</option>
<option value="painting">painting</option>

<option value="PREWRITES">PREWRITES</option>
<option value="watercolor">watercolor</option>
</select>

<br>
Assign a category:
<select id="publicpenFormInput5" name="formInputs[cbModifier26]">
<option value=""></option>
<option value="x#x#x#blankx#x#x#">No choice made</option>

<option value="oil">oil</option>
<option value="painting">painting</option>
<option value="PREWRITES">PREWRITES</option>
<option value="watercolor">watercolor</option>
</select>

<br>
Assign a category:
<select id="publicpenFormInput6" name="formInputs[cbModifier27]">
<option value=""></option>
<option value="x#x#x#blankx#x#x#">No choice made</option>
<option value="oil">oil</option>
<option value="painting">painting</option>
<option value="PREWRITES">PREWRITES</option>

<option value="watercolor">watercolor</option>
</select>

<br>
Assign a category:
<select id="publicpenFormInput7" name="formInputs[cbModifier28]">
<option value=""></option>
<option value="x#x#x#blankx#x#x#">No choice made</option>
<option value="oil">oil</option>

<option value="painting">painting</option>
<option value="PREWRITES">PREWRITES</option>
<option value="watercolor">watercolor</option>
</select>

<br>
Assign a category:
<select id="publicpenFormInput8" name="formInputs[cbModifier29]">

<option value=""></option>
<option value="x#x#x#blankx#x#x#">No choice made</option>
<option value="oil">oil</option>
<option value="painting">painting</option>
<option value="PREWRITES">PREWRITES</option>
<option value="watercolor">watercolor</option>

</select>

<br>
Assign a category:
<select id="publicpenFormInput9" name="formInputs[cbModifier30]">
<option value=""></option>
<option value="x#x#x#blankx#x#x#">No choice made</option>
<option value="oil">oil</option>
<option value="painting">painting</option>

<option value="PREWRITES">PREWRITES</option>
<option value="watercolor">watercolor</option>
</select>


</div>
<input type="hidden" name="formInputs[cbWhichType]" value="imageInfo">

<input type="hidden" name="choiceMade" value="standardImageUpload">
<input type="hidden" name="actions[choiceMade]"
value="standardImageUpload">
<input type="hidden" name="fileName" value="">
<input type="submit" value="Click here when done" class="submitInput">
</form>
Jul 17 '05 #3

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

Similar topics

1
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...
15
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...
9
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...
7
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"...
6
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...
9
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...
3
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...
5
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...
12
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"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.