Jump to content

Archived

This topic is now archived and is closed to further replies.

tjobrien21

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

Recommended Posts

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):

[code]
<!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" ;

  }
?>
~
[/code]

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

Thanks,
Tim

Share this post


Link to post
Share on other sites
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:
[code]<?php
phpinfo();
?>[/code]
Under PHP Core check for the "upload_max_filesize" field, and see you file upload limit.

Orio.

Share this post


Link to post
Share on other sites
Can we get the HTML form you're using to upload the file?

Share this post


Link to post
Share on other sites
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:

[code]
<!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>
[/code]

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.