echo 'The file type does not match! '.$_FILES['upfile']['type'];
exit;
}
if(!file_exists($destination_folder)){
mkdir($destination_folder);
}
$filename=$_FILES['upfile' ]['tmp_name'];
$image_size=getimagesize($filename);
$pinfo=pathinfo($_FILES['upfile']['name']); //File path information
$ftype=$pinfo[' extension']; //Old file extension
$destination = $destination_folder.time().".".$ftype; //New file name
if(file_exists($destination)&&$voerwrie !=true){
echo 'The file with the same name already exists! ';
exit;
}
//Move the uploaded file from the temporary folder to the specified directory
if(!move_uploaded_file($filename,$destination)){
echo 'An error occurred while moving the file! ';
exit;
}
$pinfo=pathinfo($destination);
$fname=$pinfo[basename];
echo "Uploaded successfully< br>File name:
".$destination_folder.$fname." ";
echo 'Width:'.$image_size[0];
echo 'Height:'.$image_size[1];
echo ' Size:'.$_FILES['upfile']['size']."bytes";
}
?>
Copy Code
Image upload, PHP
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn