Can't seem to get file upload working using PHP. Would appreciate any help/advice.
This is the PHP code block:
<?
$uploadDir = '/vservers/designawards/htdocs/upload/';
if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
echo "<br>File uploaded<br>";
}
?> |
Have tried all sorts of upload directory paths with appropriate permissions set. The error for the case above, when uploadDir = /vservers/designawards/htdocs/upload/ is as follows:
Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/tmp/phpAgyZ6l) is not within the allowed path(s): (/vservers/designawards) in /vservers/designawards/htdocs/uploader_z.php on line 36
Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/tmp/phpAgyZ6l) is not within the allowed path(s): (/vservers/designawards) in /vservers/designawards/htdocs/uploader_z.php on line 36
Warning: move_uploaded_file(/tmp/phpAgyZ6l) [function.move-uploaded-file]: failed to open stream: Operation not permitted in /vservers/designawards/htdocs/uploader_z.php on line 36
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpAgyZ6l' to '/vservers/designawards/htdocs/upload/error.jpg' in /vservers/designawards/htdocs/uploader_z.php on line 36
Error uploading file |
Please let me know how to fix this. Thanks in advance.