Wednesday, 24 May 2017

Error in moving file in php

I have following script which is showing me warning on move_uploaded_file.




Warning: move_uploaded_file(/home/oxfordmo/public_html/ticket/attachement/1320610829.docx) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/oxfordmo/public_html/ticket/open.php on line 53




Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpLHjtMJ' to '/home/oxfordmo/public_html/ticket/attachement/1320610829.docx' in /home/oxfordmo/public_html/ticket/open.php on line 53




 if ( $file != "" ) {
$type = $_FILES["file"]["type"];
$ext = pathinfo( $_FILES["file"]['name'], PATHINFO_EXTENSION );
if ( $ext != "doc" || $ext != "pdf" || $ext != "docx" ) {
if ( $_FILES["file"]["size"] <= 1024 * 1024 ) {
if ( file_exists( "$root/ticket/attachement/$time.$ext" ) ) {
unlink( "$root/ticket/attachement/$time.$ext" );

} elseif ( !move_uploaded_file( $_FILES["file"]['tmp_name'], "$root/ticket/attachement/$time.$ext" ) ) {
$errorfile = "Unable to move file to destination folder.";
}
$file = $time . '.' . $ext;
$query = mysql_query( "UPDATE tkt_container SET attachment='" . $file . "' WHERE ticket_id='" . $ticket_id . "'" ) or die( mysql_error() );
} else {
$errorfile = "File not saved. Size limit Exceed! ";
}
} else {
$errorfile = "File not saved. Invalid Format!";

}
}

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...