I am attempting a CMS photo gallery and need to create thumbnails at the end of my upload.php file. I have a function called create_square_image that works fine when run on the 'showphotos.php' page. However I don't want it to be run every time someone views the page. I have tried adding the following to 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);

The create_square_image function uses this format: create_square_image ( string $filename , string $destination, size )

I have tried it a few times and it will save the image but not the thumbnail.

有帮助吗?

解决方案

Set the permissions on /uploads/thumbs/ to 777. You could also try specifying the absolute path to that location. To see your absolute path use this code: echo getcwd();

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top