我正在尝试CMS照片库,需要在upload.php文件的末尾创建缩略图。我有一个名为create_square_image的函数,在"showphotos.php"页面上运行时效果良好。但是,我不希望每次有人浏览页面时都运行它。我已尝试将以下内容添加到SW上载。。。
// Process the file
/*
At this point we are ready to process the valid file. This sample code shows how to save the file. Other tasks
could be done such as creating an entry in a database or generating a thumbnail.
Depending on your server OS and needs you may need to set the Security Permissions on the file after it has
been saved.
*/
$thumb_save = "uploads/thumbs/thumb_" . $_FILES[$upload_name]["tmp_name"];
create_square_image($_FILES[$upload_name]["tmp_name"],$thumb_save,100);
if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path.$file_name)) {
HandleError("File could not be saved.");
exit(0);
}
exit(0);
create_square_image函数使用以下格式:create_square_image(字符串$filename,字符串$destination,大小)
我已经试过几次了,它会保存图像,但不会保存缩略图。
将/uploads/thumbs/
的权限设置为777。您也可以尝试指定该位置的绝对路径。要查看您的绝对路径,请使用以下代码:echo getcwd();