Post by Don WielandPost by Aziz SalehIf you show us the code it would be easier to help.
Warning: move_uploaded_file(../../../media/images/pic2.jpg): failed to
open stream: No such file or directory in
/home/rtsadven/public_html/wrightcheck/admin/resources/php/upload_image.php
on line 40 Warning: move_uploaded_file(): Unable to move '/tmp/phpKuJ4td'
to '../../../media/images/pic2.jpg' in
/home/rtsadven/public_html/wrightcheck/admin/resources/php/upload_image.php
on line 40
Here is my code - there are a few debugging echoes though - sorry
//Set the values resulting from the Upload form POST.
$tmp_name = $_FILES['file'] ['tmp_name'];
$name = $_FILES['file'] ['name'];
$size = $_FILES['file'] ['size'];
$type = $_FILES['file'] ['type'];
// $error = $_FILES['file'] ['error'];
$extension = strtolower(substr($name, strpos($name, '.') +1));
// If values are set and not empty move_upload_file is invoked to place
the uploaded file into the web server directory identified by $directory.
if (isset($name)) {
// Check for a valid image filetype.
if (!empty($name)) {
// echo 'Filename is not empty.<br><hr>';
if ($extension == 'jpg' || $extension == 'jpeg' ||
$extension == 'png' || $extension == 'gif') {
echo 'Temporary Filename: '.$tmp_name.'<br><hr>';
echo 'Actual Filename: '.$name.'<br><hr>';
$directory = '../../../media/images/';
// $directory = '../../../resources/uploads/'; This
fails also so it does not appear to be a permissions issue as we should be
able to create a file into this project directory.
$destination = $directory.$name;
'.$destination.'<br><hr>';
echo '<a href="'.$destination.'"
target="_blank">link</a><br><hr>';
if (move_uploaded_file($tmp_name, $destination)) {
// This is failing but I cannot figure out why.
I do not get an error message in the error.php file in the server directory
/edit_image/error.php like I get any other time there is a php error.
// if (move_uploaded_file($tmp_name,
'../../../resources/uploads/uploaded.jpg')) {
// echo 'Image file '.$name.' successfully
uploaded to '.$directory.'.';
echo 'Image file successfully uploaded.<br><hr>';
} else {
echo 'move_upload_file failed!<br><hr>';
}
} else {
echo '<span class="formErrorMessage">Image File
Type must be jpg, jpeg, png or gif!</span><br><br>';
}
} else {
echo '<span class="formErrorMessage">Please choose a
file to upload!</span><br><br>';
}
}