PHP upload works for some and not for others!?
Posted: Mon Aug 31, 2009 5:05 pm
I have a simple upload script installed in a website. The code checks file type and size before uploading the file to the appropriate directory. Problem I'm having is the script works perfectly well when I test it but returns an error when a client uses it even though their file meets to the requirements. The client emailed me the file that was rejected and I uploaded the same file through the same script without it being rejected. Code is:
Why does this work from some computers and not others? Please help. Thanks.
Code: Select all
<?php
$target_path = "../images/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$limit_size=5000000;
$file_size = $_FILES['uploadedfile']['size'];
if (
(
($_FILES['uploadedfile']['type'] == "image/jpeg")
|| ($_FILES["uploadedfile"]["type"] == "image/jpg")
|| ($_FILES["uploadedfile"]["type"] == "image/gif")
|| ($_FILES["uploadedfile"]["type"] == "image/png")
)
&& (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
&& ($file_size <= $limit_size)
)
{
echo "<p>The file ". basename( $_FILES['uploadedfile']['name']).
" has been successfully uploaded.</p>";
}
else{
echo "<p><b>There was an error uploading the file,</b> please try again! Make sure your file is under 5 Mbs and is in one of the following formats: jpeg, gif or png.</p>";
}
?>