Re: file upload problem
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Sun, 09 Mar 2008 20:32:45 -0500
mike wrote:
Hi,
Thank you to those that helped with the php.ini problem.
Now my real problem, I am very new to php. I am trying to learn about uploading files with php. I made a simple form script and and file up load script. Right now I am really just tring to move a file from one directory to another.
The form script gets the file name correctly and seems to pass it to the upload script correctly. However the movement of the file to the new directory never occurs because of an error Value: 6; Missing a temporary folder. However, if I look at the phpinfo() results I see that 'upload_tmp_dir' directory is set to a valid directory (same one that is in the php.ini file). Also, if I echo ini_get('upload_tmp_dir') I see
the same valid directory. So I am not sure why the error.
Note also if I uncomment the line:
//$tmp_file = $_FILES['userfile']['tmp_name']
in the upload script, the process seems to abort I just get a blank browser screen.
Q:Any ideas on why the temp directory path/ file name is not getting set
Thanks
Mike
My scripts are below:
*****************************************
File Form
***************
<html>
<body>
<?php echo '<p>Hello World</p>'; ?>
<?php
$b=ini_get('upload_tmp_dir');
$c=ini_get('SMTP');
echo "temp dir is = $b <br /> ";
echo "localhost is $c = <br /><br />";
?>
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="http://localhost/php/upload.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>
</body>
</html>
**********************************************
File Upload
******************
<html>
<body>
<?php
$b=ini_get('upload_tmp_dir');
$c=ini_get('SMTP');
echo "temp directory is = $b <br /> ";
echo "localhost is = $c <br /><br />";
$uploaddir = 'C:\Inetpub\wwwroot\php_testfiles\upload\\';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
//$tmp_file = $_FILES['userfile']['tmp_name']
echo "uploaddir = $uploaddir <br />";
echo "uploadfile = $uploadfile <br />";
//echo "$tmp_file = $tmp_file <br /><br />";
echo '<pre>';
echo ini_get('upload_tmp_dir');
echo 'Here is some pre debugging info:<br />';
print_r($_FILES);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack problem\n";
}
echo 'Here is some post debugging info:';
print_r($_FILES);
print "</pre>";
?>
</body>
</html>
*************************************************
Results
******************
temp directory is = C:\DOCUME~1\MIA-KI~1\LOCALS~1\Temp\php\upload
localhost is = localhost
uploaddir = C:\Inetpub\wwwroot\php_testfiles\upload\
uploadfile = C:\Inetpub\wwwroot\php_testfiles\upload\optoutalrt.pdf
C:\DOCUME~1\MIA-KI~1\LOCALS~1\Temp\php\uploadHere is some pre debugging info:Array
(
[userfile] => Array
(
[name] => optoutalrt.pdf
[type] =>
[tmp_name] =>
[error] => 6
[size] => 0
)
)
Possible file upload attack problem
Here is some post debugging info:Array
(
[userfile] => Array
(
[name] => optoutalrt.pdf
[type] =>
[tmp_name] =>
[error] => 6
[size] => 0
)
)
Does your webserver userid have write access to the temporary directory?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: file upload problem
- From: mike
- Re: file upload problem
- References:
- file upload problem
- From: mike
- file upload problem
- Prev by Date: Re: php.ini set up problem
- Next by Date: Re: Session timeout
- Previous by thread: file upload problem
- Next by thread: Re: file upload problem
- Index(es):
Relevant Pages
|