faqts : Computers : Programming : Languages : PHP : Common Problems : File Uploading

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

132 of 250 people (53%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

Warning: open_basedir restriction in effect. File is in wrong directory in /home/httpd/vhosts/corvet

Sep 8th, 2002 12:09
Reza A Tabibazar, Chris Name,


That is because  the safe mode is turned on. 
Just use move_uploaded_file() instead of copy()
working example;
-----------------------------
<HTML>
<TITLE>
File upload
</title>
<body>
<B>File upload</b>
<form enctype="multipart/form-data" action="<?PHP echo $PHP_SELF ?>" 
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
Send this file: 
 <input name="userfile" type="file">
<input type="submit" name="submit" value="Send File">
</form>
</body>
<?PHP
// copy to this directory
$dir="./uploads/";
// copy the file to the server
if (isset($submit)){
if (!is_uploaded_file ($userfile)){
   echo "<b>$userfile_name</b> couldn't be copied !!";
}
// check whether it has been uploaded
if (is_uploaded_file ($userfile)){
  move_uploaded_file($userfile,$dir.$userfile_name) ;}
   echo "<b>$userfile_name</b> copied succesfully !!";
}
?>
</html>