Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not able to upload images, but can upload text files

Status
Not open for further replies.

Slimsteve

Technical User
Jun 10, 2003
67
GB
Hi,

I have a php upload script, but it will only upload text files and not images. Can anyone see why I cannot upload any image files like jpegs or gifs.

Code:
<form enctype="multipart/form-data" action="modimagesupload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input class="inputbox" type="file" name="pictures[]"  size="79">
<input type="submit">
</form>

Code:
<?php

foreach ($_FILES["pictures"]["error"] as $key => $error) {
echo $_FILES["pictures"]["type"][$key];
   if ($error == UPLOAD_ERR_OK) {
       $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
       $name = $_FILES["pictures"]["name"][$key];
       if(move_uploaded_file($tmp_name, "images/$name"))
       {
              // we know the move_upload worked, so back it up
              copy("images/$name", "backupimages/$name");
       }

   }
}

print '<pre>';
print_r ($_FILES);
?>
 
is the image file you are using to test definitely smaller than 30k? try adding another couple of zeros to the max_upload and re-testing. also check the file upload size constraints in your php directive

also i'm not sure that your receiving script will work if you have more than one file field (you are calling it an array). don't you need to examine the $_FILES['pictures'][n]['errors'] element?
 
some of that script looks scarily familiar :)

As jpadie says, you need to review how you handle the uploaded array of files.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 

Your right, the issue is the file limitation, thats what I get when I copy an paste from another script I was working on.

Thanks

Slim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top