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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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();".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.