Even though this is called the Upload Class, you can apply the same methods to files already on your server
如何使用
按照网站上的安装说明,简单地下载课程并将其放在您的网站上 .
您的脚本将如下所示:
// Include the upload class
include('class.upload.php');
// Initiate the upload object based on the uploaded file field
$handle = new upload($_FILES['image_field']);
// Only proceed if the file has been uploaded
if($handle->uploaded) {
// Set the new filename of the uploaded image
$handle->file_new_name_body = 'image_resized';
// Make sure the image is resized
$handle->image_resize = true;
// Set the width of the image
$handle->image_x = 100;
// Ensure the height of the image is calculated based on ratio
$handle->image_ratio_y = true;
// Process the image resize and save the uploaded file to the directory
$handle->process('/home/user/files/');
// Proceed if image processing completed sucessfully
if($handle->processed) {
// Your image has been resized and saved
echo 'image resized';
// Reset the properties of the upload object
$handle->clean();
}else{
// Write the error to the screen
echo 'error : ' . $handle->error;
}
}
2 回答
您只需要宽高比 . 这些方面的东西:
您需要添加一些错误检查,但这应该让您开始 .
使用Colin Verot编写的上传类 . 它有各种选项可用于调整大小,编辑,水印等......真棒!
该课程由互联网上的网站维护和使用,因此您可以信赖它是可靠的!
见here
Even though this is called the Upload Class, you can apply the same methods to files already on your server
如何使用
按照网站上的安装说明,简单地下载课程并将其放在您的网站上 .
您的脚本将如下所示: