Jump to content


Photo

File Upload - can only upload very small (60K) files - bigger files fail


  • Please log in to reply
3 replies to this topic

#1 tjobrien21

tjobrien21
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 03 October 2006 - 02:52 PM

Hi. :) I'm working on a file uploader, and for some reason it only works with very small files - 60K or so. A 300K file will fail. I googled and found all kinds of info about this happening with files over 2M, and having to make adjustments to php.ini... But this isn't anywhere near that limit, and when Googling I don't see others describing problems with files so small.

Here's the upload script (once I can get it to function like I want, I have session control, security, etc to add):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../pk8.css">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>Site Title</title>
</head>
<html>
<?php
   $target_path = "/home/pk8/htdocs/downloads/";
   $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

   if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
      echo "The file ".  basename( $_FILES['uploadedfile']['name']).
      " has been uploaded.<br>";
      if (chmod( $target_path , 0664 )) {
         echo "Permissions set.<br>\n" ;
      } else {
         echo "Permission set <b>failed</b><br>\n" ;
      }

   } else {
      echo "There was an error uploading the file, please try again!<br>";
      echo "target path is $target_path .<br>\n" ;

   }
?>
~

I can post php.ini or anything else that's needed. I'd appreciate any help that's available!! :)

Thanks,
Tim



#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 03 October 2006 - 05:08 PM

When you try to upload a file that it's size is, let's sy, 300K- it outputs:
"There was an error uploading the file, please try again!", or a PHP error? If it's a PHP error please post it.

In addition, run a php file with the following code:
<?php
phpinfo();
?>
Under PHP Core check for the "upload_max_filesize" field, and see you file upload limit.

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 03 October 2006 - 05:28 PM

Can we get the HTML form you're using to upload the file?
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#4 tjobrien21

tjobrien21
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 03 October 2006 - 07:09 PM

The error is "There was an error uploading the file, please try again!".. Which technically would indicate a problem copying the file, though I can't see why (the smaller files work fine, and the disk isn't full).

Here's the html form that submits the file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../pk8.css">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>Form Title</title>
</head>
<body>
   <form enctype="multipart/form-data" action="ulf.php" method="POST">
   <input type="hidden" name="MAX_FILE_SIZE" value="70000" />
   Choose a file to upload: <input name="uploadedfile" type="file" /><br />
   <input type="submit" value="Upload File" />
   </form>
</body>
</html>

And I see my own problem... And it's embarassing. However, I hate it when I google, see what I'm looking for in a forum, then someone just posts "I found and fixed the problem" and never posts the answer... So, for posterity, here goes:

It's in the MAX_FILE_SIZE form element within the HTML. How embarassing. I cut and pasted an example form after my headers to get started, and when things went awry I never looked there - just at the PHP and server config (which I thought was correct, and it turns out, it is correct).

I'm a putz  ::). Ok, maybe not a putz, but I can't believe I missed something so obvious. Thanks a bunch for pointing me in the right direction!!

Tim





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users