Hi everyone, im very happy that I managed to find a solution that gets around the openbase_dir error that my Plesk server throws up whenever I try a form based upload.
here is my code called upload.php, it successfully uploads a file, but returns an error when I try to unlink the temp file.
Does anyone know how to delete the file created in the /tmp/ dir ? currently it returns
Warning: Unlink failed (No such file or directory) in /home/httpd/vhosts/domain.com/httpdocs/upload.php on line 26
I don't want to end up with a squillion files in the /tmp/ directory........
much thanks and I hope this helps everyone who is trying to get around this problem too.
regards,
Michael
<?
if(!$upload_file)
{
?>
<form name="form1" method="post" action="upload.php?upload_file=1" enctype="multipart/form-data">
<input type="file" name="userfile"><input type="submit" name="Submit" value="Submit">
</form>
<?
}
elseif($upload_file==1)
{
$file_name = $HTTP_POST_FILES['userfile']['name'];
echo"File_name = $file_name<br>";
$tmp_name = $HTTP_POST_FILES['userfile']['tmp_name'];
echo"File tmp name = $tmp_name<br>";
$path = "/home/httpd/vhosts/domain.com/httpdocs/photos/";
echo"Path is $path<br>";
$pathfilename = "$path$file_name";
echo"pathfilename = $pathfilename<br>";
if(move_uploaded_file ($tmp_name, $pathfilename))
{
echo"$file_name ($tmp_name) successfully uploaded to $pathfilename<br>";
chmod($pathfilename, 0644);
echo"Chmod successful";
if(unlink($tmp_name))
{
echo"File $tmp_name deleted<br>";
}
}
else{echo"Could not move uploaded file";}
}
?>