Use move_uploaded_file() instead of copy()

fr r wrote:

i'm trying to do a very simple thing:
upload image but it keep giving me this error although i gave permession on folder:
Warning: open_basedir restriction in effect. File is in wrong directory in /var/www/vhosts/negoumelshasha.com/httpdocs/test4.php on line 9
and here is my code:
//////////////////////////////////////////////////////////////////////////////////////////////
<HTML><BODY BGCOLOR=FFFFFF> <?php $uploadDir = $DOCUMENT_ROOT . "/test/";
if (isset($submit))
{ if ($upload != 'none')
{ $dest = $uploadDir . $upload_name; if (copy($upload, $dest))
{ echo "Successfully uploaded $dest<BR>\n"; } else
{ echo "<FONT COLOR=FF0000><B>File Upload Failed</B></FONT><BR>\n"; $perms = @fileperms($uploadDir); $owner = @fileowner($uploadDir); if (!$perms)
{ echo "Directory does not exist: $uploadDir<BR>\n"; } else
{ $myuid = getmyuid(); if (!($perms & 2) && !(($owner == $myuid) && ($perms & 128)))
{ echo get_current_user(), " doesn't have permission to write in $uploadDir<BR>\n"; } } } } else
{ echo "<FONT COLOR=FF0000><B>File2 Upload Failed</B></FONT><BR>\n"; echo "Filesize exceeds limit in FORM or php.ini<BR>\n"; } } ?> <FORM ENCTYPE=multipart/form-data ACTION=test4.php METHOD=POST> <INPUT TYPE=HIDDEN NAME=MAX_FILE_SIZE VALUE=10000> Upload File: <INPUT NAME=upload TYPE=FILE><BR> <INPUT TYPE=SUBMIT NAME=submit VALUE="Upload"> </FORM> </BODY></HTML>



---------------------------------
Do you Yahoo!?
Free online calendar with sync to Outlook(TM).




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



Reply via email to