i'm trying to set up my site so that I can use a mobile device to upload an image. However whenever I attempt to upload the image it doesn't work and throws out two errors:
Warning: move_uploaded_file(UPLOADS/Image Attachment 27/03/16.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home3/hutch/public_html/stencylcollins/upload1.php on line 29
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpSZy8LW' to 'UPLOADS/Image Attachment 27/03/16.jpg' in /home3/hutch/public_html/stencylcollins/upload1.php on line 29
And after this I get my echo
UPLOAD SUCCESSFUL: Your document has now been uploaded and is ready to send.
Anyone know what's going on here?
<?php
//login
ob_clean();session_start();
if (isset($_GET['logout'])){
session_destroy();
}
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) {
header("Location: index.php");
}
//timezone
date_default_timezone_set('Europe/London');
$date = date('d/m/y', time());
//upload
if(isset($_FILES['UploadFileField'])){
$allowed = array('jpg','png','jpeg');
$name = $_FILES["UploadFileField"]["name"];
$tmp = $_FILES['UploadFileField']['tmp_name'];
$type = $_FILES['UploadFileField']['type'];
$newName = "Image Attachment ".$date.".jpg";
$types = array('jpg','png','jpeg');
$ext = pathinfo($name, PATHINFO_EXTENSION);
if(in_array($ext,$types)){
move_uploaded_file($tmp, "UPLOADS/$newName");
echo '<font color="#006600" size="3"><p align="center"><b>UPLOAD SUCCESSFUL: </font><font color="#000000" size="3">Your document has now been uploaded and is ready to send.</b></p></font>';
}
else {
if(!$tmp){
echo '<font color="#FF0000" size="3"><p align="center"><b>UPLOAD FAILED: </font><font color="#000000" size="3">No document has been selected.</b></p></font>';
}
else {
echo '<font color="#FF0000" size="3"><p align="center"><b>UPLOAD FAILED: </font><font color="#000000" size="3">Uploaded document was an incorrect extension type, please use ".jpg", ".jpeg", or "png" only.</b></p></font>';
}
}
}
?>
UPLOADS
isn't the same asuploads
. Plus, I see a GET array, so make sure the form isn't using GET as opposed to POST including a valid enctype. – Funk Forty Niner