Jump to content

Can php trigger another php script?


bobinindia

Recommended Posts

I am uploading images and then resampling them using GD.

If someone uploads a 5mb image it takes a while to be resampled.

I want the upload script to trigger the  resampling script and then complete itself while the resampling is still going on. User doesn't have to wait.

Possible??

Link to comment
https://forums.phpfreaks.com/topic/101767-can-php-trigger-another-php-script/
Share on other sites

The only thing I can think of is using a class and you call it with the new $method; function.

 

Although i'm not sure really this should be a single file that you put into a page in an I-Frame so people can still half use the site.

 

Not sure how to go about it but give using a class a go with I-Frames.

the method that i have used in the past is to run a cron job that checks for a new upload (or whatever) and processes it when found. after the process is complete, the record for the updated file is updated to 'complete' (or whatever), so PHP can tell the process is finished and let the user know.

 

You can't do this in PHP.

 

You need to use JS (like mootools.net) to send an AJAX request to the server and have one instance of PHP cropping the image and the user will be free to go on and send more ajax requests or visit another page without killing the cropper PHP request.

 

The second way would be to upload the file and add a record a database table "crop_jobs" that is checked by cron on the server every 10-30mins and all filenames in that table are cropped and the DB rows deleted without need for the users do wait for the process. In the mean time you could just say "server is processing your image" on each page.

 

You can't start a php request and go on to something else and expect it to continue. I.E. "set_time_limit", "die()", or "exit();".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.