php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10514 Uploaded file not stored in "upload_tmp_dir"
Submitted: 2001-04-26 13:24 UTC Modified: 2001-11-28 08:46 UTC
From: fhamonno at club-internet dot fr Assigned:
Status: Not a bug Package: PHP options/info functions
PHP Version: 4.0.4pl1 OS: Linux server27.promotion-web.net
Private report: No CVE-ID: None
 [2001-04-26 13:24 UTC] fhamonno at club-internet dot fr
On the server, and according to phpInfo(), main PHP variables are:
Apache Version = Apache/1.3.19 
Apache Release = 10319100 
Apache API Version = 19990320 
User/Group = nobody(99)/99
Loaded Modules = mod_php4, .....

Session Support = enabled
session.auto_start = Off

upload_max_filesize = 1000000
upload_tmp_dir = ./tmp/

I'm running the script below; it's located in a directory where has been created a directory "tmp" (so the path "./tmp/" is OK) with rights set to "777" (chmod):

<HTML>
<HEAD><TITLE>Upload Test</TITLE></HEAD>
<BODY>
<?
// Test Upload
//
// La premi?re fois, "action" n'est pas renseign?
// => le formulaire est affich?
// A l'envoi du formulaire, "action" est renseign?
// => le script affiche les param?tres du fichier t?l? charg?
//    et affiche le d?but du fichier

if ( !$action ) {

// Affichage du formulaire

  echo "<form enctype=multipart/form-data action=".$PHP_SELF."
method=POST>\n";
  echo "<input type=hidden name=MAX_FILE_SIZE value=100000>\n";
  echo "Send this file: ";
  echo "<input name=userfile type=file>\n";
  echo "<input type=hidden name=action value=show_me_the_file>\n";
  echo "<input type=submit value=Send File>\n";
  echo "</form>\n";

} else {

// Affichage des param?tres du fichier t?l?charg?

  echo "<h2>Size: $userfile_size</h2>\n";
  echo "<h2>Type: $userfile_type</h2>\n";
  echo "<h2>Name: $userfile_name</h2>\n";
  echo "<h2>File: $userfile     </h2>\n";

// Listing du r?pertoire "./tmp"

  $dir='./tmp';
  $handle=opendir($dir);
  echo "<p>Pointeur de dossier: $handle\n";
  echo "<br>Fichiers de $dir:\n";
  while ($fic = readdir($handle)) {
  echo "<br>$fic\n";
  }
  closedir($handle); 
  echo "<br>\n";

// Suppression des doubles slash dans le nom de fichier

  $file=ereg_replace("//+","/",$userfile);

// Lecture et affichage du d?but du fichier

  $fd=fopen($file,"r") or die ("Unable to open uploaded file!");
  $data=fread($fd, MAX_SIZE);
  fclose($fd);
  echo "Beginning of file: ".substr($data, 0, 25);
  
}
?>
</BODY>
</HTML>
<!-------------------------------------------------------->

The variables displayed are the one expected (user's file name, type, size), the temp file has a coherent name ("./tmp/phpxxxxxx")... but upload directory "./tmp" remains empty.
There is no error generated in "error.log" during PHP recovery of uploaded file. An error occurs when the script try to access the file.

I've double-checked everything I could think of...

The problem exposed seems to be the same as the one posted with Bug id #10386.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-28 08:46 UTC] sander@php.net
This is what Cardinal said about this in bug #10386
---
[2001-05-07 18:58:31] 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.
---
Not a bug. 
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jul 11 17:01:27 2020 UTC