Hi,
I am working on getting a file upload script working. I am trying to get the example that is used on the PHP.net site. Here is my code:
test.html:
Then the fileUpload.php:
The print out is as follows:
here
C:\WINDOWS\TEMP\php10.tmp
Todo.txt
Array
(
[userfile] => Array
(
[name] => Todo.txt
[type] => text/plain
[tmp_name] => C:\WINDOWS\TEMP\php10.tmp
[error] => 0
[size] => 814
)
)
Error = 0
Thus, it says the error code is 0 (which according to PHP.net means the upload was successful). However, the file does not exist in the folder I chose, and if it is printing Error = 0, it means that move_file returned false.
Any help here would be appreciated.
Keith
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
I am working on getting a file upload script working. I am trying to get the example that is used on the PHP.net site. Here is my code:
test.html:
Code:
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="fileUpload.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
Then the fileUpload.php:
Code:
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
print "<pre>";
if(is_uploaded_file($_FILES['userfile']['tmp_name']))
{
print "here\n";
print $_FILES['userfile']['tmp_name']."\n";
print $_FILES['userfile']['name']."\n";
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']))
print('here2');
else
{
print_r($_FILES);
print "Error = ".$_FILES['userfile']['error'];
}
}
else
{
// file not uploaded to server
print('else');
}
print "</pre>";
?>
The print out is as follows:
here
C:\WINDOWS\TEMP\php10.tmp
Todo.txt
Array
(
[userfile] => Array
(
[name] => Todo.txt
[type] => text/plain
[tmp_name] => C:\WINDOWS\TEMP\php10.tmp
[error] => 0
[size] => 814
)
)
Error = 0
Thus, it says the error code is 0 (which according to PHP.net means the upload was successful). However, the file does not exist in the folder I chose, and if it is printing Error = 0, it means that move_file returned false.
Any help here would be appreciated.
Keith
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.