Below I have listed the web server configuration et.al. and the
*.php files that I am using to try to do a file upload. I have
also listed the output that I an getting from the IE5 browser.
Can anyone figure out what I am doing wrong? I suspect that I
have a server config problem.
Thanks in advance!!
CONFIGURATION
FreeBSD 4.2-STABLE, Apache/1.3.17 mod_ssl/2.8.0, PHP Version 4.0.5
The directories /tmp and /usr/local/tmp have completely open
permissions (777) and neither is in the DocumentRoot area.
BTW. I am using virtual hosting if that matters.
FILE: php.ini
file_uploads: 1
safe_mode: Off
upload_max_filesize: 2M
upload_tmp_dir: /tmp
FILE: upform.php
<head>
</head>
<body>
<form enctype=multipart/form-data" action="upload.php" method=post>
File: <input type="file" name="userfile">
<input type="submit" value="Submit">
<input type="hidden" name="MAX_FILE_SIZE" value="20000">
</form>
</body>
FILE: upload.php
<head>
</head>
<body>
<?
$userfile = stripslashes($userfile);
$updir = "/tmp/";
$todir = "/usr/local/tmp/";
echo 'userfile:-'.$userfile.'-<br>';
echo 'userfile_name:-'.$userfile_name.'-<br>';
echo 'userfile_size:-'.$userfile_size.'-<br>';
echo 'userfile_type:-'.$userfile_type.'-<br>';
echo 'HTTP_POST_FILES:-'.$HTTP_POST_FILES['userfile']['name'].'-<br>';
if ( !copy($userfile, $todir.$userfile_name))
{
echo "Problem: Could not move file into directory".$upfile;
exit;
}
echo "File uploaded successfully<br><br>";
?>
</body>
RESULTING DISPLAY
userfile:-C:\aaa.txt-
userfile_name:--
userfile_size:--
userfile_type:--
HTTP_POST_FILES:--
Warning: Unable to open 'C:\aaa.txt' for reading:
No such file or directory in /usr/local/.../upload.php on line 17
Problem: Could not move file into directory /usr/local/tmp/