Home » HTTP » HTTP_Upload » Bug #5432
File is uploaded with a different name
Details
| Submitted | 2005-09-16 15:16 UTC |
|---|---|
| From | mohsenkashani at hotmail dot com |
| Status | Bogus |
| Package | HTTP_Upload |
| PHP Version | 4.3.2 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2005-09-16 15:16 UTC] mohsenkashani at hotmail dot com
Description:
------------
I used a test script, the file was uploaded but the file name was changed to a series of hex digits:
Uploaded main_withlines.jpg as 474144959432add7537fa1.jpg in ./uploads/
Array
(
[real] => main_withlines.jpg
[name] => 474144959432add7537fa1.jpg
[form_name] => pictures
[ext] => jpg
[tmp_name] => /tmp/phpWhb1n9
[size] => 78800
[type] => image/jpeg
[error] =>
)
The file is actually saved as 474144959432add7537fa1.jpg.
Test script:
---------------
I used the example script included with the downloaded package:
<html><body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>?submit=1" method="post" enctype="multipart/form-data">
Send these files:<br>
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input name="userfile" type="file"> <-<br>
<input name="otherfile[]" type="file"><br>
<input name="otherfile[]" type="file"><br>
<input type="submit" value="Send files">
</form>
</body></html>
<?php
error_reporting(E_ALL);
if (!isset($submit)) {
exit;
}
require 'HTTP/Upload.php';
echo '<pre>';
//print_r($HTTP_POST_FILES);
$upload = new http_upload('en');
$file = $upload->getFiles('userfile');
if (PEAR::isError($file)) {
die ($file->getMessage());
}
if ($file->isValid()) {
$file->setName('uniq');
$dest_dir = './uploads/';
$dest_name = $file->moveTo($dest_dir);
if (PEAR::isError($dest_name)) {
die ($dest_name->getMessage());
}
$real = $file->getProp('real');
echo "Uploaded $real as $dest_name in $dest_dir\n";
} elseif ($file->isMissing()) {
echo "No file selected\n";
} elseif ($file->isError()) {
echo $file->errorMsg() . "\n";
}
print_r($file->getProp());
echo '</pre>';
?>
Expected result:
----------------
I expected the file to be uploaded with the same name, not changed to a bunch of hex digits.
Actual result:
--------------
Uploaded main_withlines.jpg as 474144959432add7537fa1.jpg in ./uploads/
Array
(
[real] => main_withlines.jpg
[name] => 474144959432add7537fa1.jpg
[form_name] => pictures
[ext] => jpg
[tmp_name] => /tmp/phpWhb1n9
[size] => 78800
[type] => image/jpeg
[error] =>
)
When I check the folder ./uploads, the only file listed is 474144959432add7537fa1.jpg.