php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10386 Uploaded files do not save.
Submitted: 2001-04-18 17:25 UTC Modified: 2001-05-10 18:07 UTC
From: kyle at discoverdhs dot com Assigned:
Status: Closed Package: HTTP related
PHP Version: 4.0.4 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-04-18 17:25 UTC] kyle at discoverdhs dot com
I am not sure where the fault lies here... (very possibly on me)

All of the variables in $HTTP_POST_FILES are correct, yet the file doesn't actually save. I'm running PHP as Administrator, so I don't think it's a problem with permissions.

My upload_tmp_dir is set to "c:\windows\temp" and when I upload a file.. it does not appear there. I've also tried setting upload_tmp_dir to "\", "\windows\temp" and checked $HTTP_POST_FILES["song"]["tmp_name"] to be sure... still no luck.

  <form action="<? print($PHP_SELF); ?>" method="POST" enctype="multipart/form-data">
   <table width="100%" cellpadding="4" cellspacing="0" border="0">
    <tr>
     <td>Title: </td>
     <td><input type="text" name="title"></td>
    </tr>
    <tr>
     <td>Artist: </td>
     <td>
      <select name="artist">
       <? print(artists_formatted()); ?>
      </select>
     </td>
    </tr>
    ...
    <tr>
     <td>Upload: </td>
     <td><input type="file" name="song"></td>
    </tr>
   </table>
   <input type="hidden" value="upload" name="do">
   <input type="hidden" value="8192" name="MAX_FILE_SIZE">
   <input type="submit" value="Upload">

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-21 15:46 UTC] kyle at discoverdhs dot com
Just as another test, I tried changing the MAX_FILE_SIZE to a larger number (1000000000000) but it still failed to upload. I also double checked that Apache was running as "Administrator"... I can't figure this out for the life of me.
 [2001-05-07 18:58 UTC] cardinal@php.net
If you're expecting uploaded files to stay there, that won't happen.  Once the file has been uploaded and the script finishes running, PHP will remove the file (Hence 'upload_tmp_dir').  In order to keep the file, you need to copy it to another location.

If you are already copying it somewhere, could you include a short, reproducible script that demonstrates the bug?

 [2001-05-10 18:06 UTC] kyle at discoverdhs dot com
The problem was with my code. I didn't think to copy the files to a new location... I assumed they were handled differently. Sorry for the trouble :)
 [2001-05-10 18:07 UTC] derick@php.net
User says it's a bug in his own code, so closing.
 [2004-09-22 09:06 UTC] prashant_dnmmkpk at yahoo dot com
Hi.
Im new to PHP. I've written a code to upload a text file and find the number of lines in that file. The file is uploading to a temp file but it is not saving to other location.

Below is the code i've used.
  if (copy($HTTP_POST_FILES['userfile']['tmp_name'], "/modules/uploader/upload/"))
	 {

         $filesize = filesize("modules/uploader/upload/" . $title);
         $filesize = ereg_replace("\.", "", $filesize);
         $filesize = ereg_replace("\,", "", $filesize);
        
        $aryInput = file("modules/uploader/upload/$title", "r");
         $arycount = count($aryInput);

         if ($arycount != $numrec){
             echo "<center><font class=\"pn-normal\"><font color=\"red\"><u>You have entered some incorrect values</u></font><br><br>";
                      
             return false;
             }
        
         return true;
         }
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed May 22 23:01:33 2019 UTC