I set up a form that sends info to a sql db and uploads a pic to a directory on the site. Everything is being put into the db table correctly the only thing that is going wrong is the picture being put into the directory. It comes back with this error:
Warning: move_uploaded_file(../mrlogo/uploads/business_man.jpg): failed to open stream: No such file or directory in /home/u5/msampo1/html/mrlogo/admin/validatefile.php on line 98
Warning: move_uploaded_file(): Unable to move '/var/tmp/phpoD2ca5' to '../mrlogo/uploads/business_man.jpg' in /home/u5/msampo1/html/mrlogo/admin/validatefile.php on line 98
The directory exists I know that for a fact. I am too new to this to understand what it means.
here is the upload script for the picture
<?php
//validates the file being uploaded to the server
foreach($_FILES as $value) {
foreach($value as $k => $v) {
echo $k.' => '.$v.'<br>';
}
}
?>
<?php
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES
if($_FILES['userfile']['name'] == '') {
echo 'You did not select a photo to upload';
}
elseif($_FILES['userfile']['size'] == 0) {
echo 'There appears to be a problem with the photo your are uploading';
}
elseif($_FILES['userfile']['size'] > $MAX_FILE_SIZE) {
echo 'The photo you selected is too large';
}
elseif(!getimagesize($_FILES['userfile']['tmp_name'])) {
echo 'The photo you selected is not a valid image file';
}
else {
$uploaddir = '../mrlogo/uploads/'; // remember the trailing slash!
$uploadfile = $uploaddir. $_FILES['userfile']['name'];
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo '<b><font color="green"><b>Upload file success!</b><br></font>';
}
else {
echo '<br><font color="red"><b>There was a problem uploading your file. If the problem continues please contact your administrator.</b><br></font>';
print_r($_FILES);
}
}
?>
Can someone tell me what could be the issue? I have tried everyhting with trying to fix this.