使用SWFUpload创建缩略图

时间:2012-02-12 18:47:38

标签: php thumbnails multi-upload

我正在尝试CMS照片库,需要在upload.php文件的末尾创建缩略图。我有一个名为create_square_image的函数,在'showphotos.php'页面上运行时可以正常工作。但是,我不希望每次有人查看页面时都会运行它。我尝试将以下内容添加到SWFUpload ...

// 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(string $ filename,string $ destination,size)

我已经尝试了几次,它会保存图像而不是缩略图。

1 个答案:

答案 0 :(得分:0)

/uploads/thumbs/上的权限设置为777.您还可以尝试指定该位置的绝对路径。要查看绝对路径,请使用以下代码:echo getcwd();