I'm attempting to get file uploads via a HTML form to work. I've been 
working on this for a couple of days, reading the PHP.net manual, and 
searching the newsgroups and various web sites. Haven't come up with a 
solution to my problem.

Basically I'm unable to upload any files to my web site. I don't have 
control over the server since my site is hosted. Here is the error messages 
I'm getting followed by the code.

** HTML output: **
User file: /tmp/phpEhNNmW
User filename: biglaugha.gif
User file size: 1370
User file type: image/gif

Testing short track var names.
$_FILES['userfile']['tmp_name']: /tmp/phpEhNNmW
$_FILES['userfile']['name']: biglaugha.gif

Warning: open_basedir restriction in effect. File is in wrong directory
in /usr/local/psa/home/vhosts/logicalsystem.com/httpdocs/up_load.php on
line 18 

Warning: Unable to create '/httpdocs/biglaugha.gif': No such file or
directory in
/usr/local/psa/home/vhosts/logicalsystem.com/httpdocs/up_load.php on
line 23 

Warning: Unable to move '/tmp/phpEhNNmW' to '/httpdocs/biglaugha.gif' in
/usr/local/psa/home/vhosts/logicalsystem.com/httpdocs/up_load.php on
line 23 
** end of output **


** HTML/PHP file containing the form **
<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Test Upload</TITLE>
</HEAD>
<BODY>
        <FORM action="up_load.php" method="post" enctype="multipart/form-
data">          
                <INPUT type="hidden" name="MAX_FILE_SIZE" value="100000">Send 
this file:              
                <INPUT name="userfile" type="file">             
                <INPUT type="submit" value="Send File">
        </FORM>
</BODY>
</HTML>
** end of file **

** PHP files that processes the submitted form(up_load.php) **
<?php 
//Print some vars for debugging
print "<strong>User file:</strong> $userfile";
print "<br>";
print "<strong>User filename:</strong> $userfile_name";
print "<br>";
print "<strong>User file size</strong>: $userfile_size";
print "<br>";
print "<strong>User file type:</strong> $userfile_type";
print "<br>";
print "<br>Testing short track var names.<br>";
print "<strong>\$_FILES['userfile']['tmp_name']:</strong> ".$_FILES
['userfile']['tmp_name'];
print "<br>";
print "<strong>\$_FILES['userfile']['name']:</strong> ".$_FILES['userfile']
['name'];
print "<br>";

// In PHP 4.1.0 or later, $_FILES should be used instead of 
$HTTP_POST_FILES.
//This code is a direct lift from the PHP.net site.
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) 
{
    //made some changes to this line to reflect target directory.
    //I also have another directory /httpdocs/tmp that has rwx for world.
    //Same results
    copy($HTTP_POST_FILES['userfile']['tmp_name'], "/httpdocs/");
} else {
    echo "Possible file upload attack. Filename: " . $HTTP_POST_FILES
['userfile']['name'];
}
/* ...or... */
move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], "/httpdocs/
$userfile_name");
?>
** end of file **

** Some vars returned using phpinfo() **
safe_mode: On 
open_basedir: /usr/local/psa/home/vhosts/logicalsystem.com/httpdocs
upload_tmp_dir: /tmp

PHP is version 4.1.0

The end goal is to put the data into a database. I've used the fopen and 
fread functions with not success. I backed off and tried the example from 
the PHP.net manual and that doesn't work either. This appears to be a 
problem with safe mode and/or open_basedir being set. Is there a work 
around or something? 

Thanks!
Jack

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to