Reply to Re: How to properly handle lengthy operations?

Your name:

Reply:


Posted by Erwin Moller on 09/12/06 06:34

Jonah Bishop wrote:

> I'm developing a photo album web application for use on a web site, and
> I'm running into a problem with lengthy operations. My application
> allows the user to import a number of images at once into a photo
> album. For each image that gets imported, I create two thumbnail images
> (small and medium) and insert some data into a database. The thumbnail
> generation process takes some time and, for relatively large amount of
> photos, the application apparently times out. For example, if I import
> 40 pictures at once, 15 or so get imported successfully, but the app
> then seems to time out. So I then have to import the images that are
> left (that didn't get imported).
>
> How can I properly handle such a lengthy operation? Ideally, I would
> like to let the user know what's going on (and how much progress has
> been made). And I certainly want all of the photos (no matter how many)
> to be imported at once.
>
> Are there programming paradigms that work well for situations like
> this? What tips do people here have for such a situation? Any help
> would be greatly appreciated! Thanks.

Hi,

You should have a look at script timeout.
This can be modified in php.ini or via ini_set().

Here is more info on all settings:
http://nl2.php.net/manual/en/ini.php

Some relevant settings:
- max_execution_time
to set the time your script can take to finish.
- post_max_size
to change the amount of data a user can post (this includes the file you
want to upload)
- memory_limit
to give PHP more memory.

If you want to report back to the user how far your computations went,
simple use outputbuffering and flush everytime a line to the clientbrowser.
eg: finished picture 5 of 36

Check www.php.net for ob_start() and ob_flush().
(I am unsure if you actually need ob_start when using ob_flush, but it
doesn't hurt.)

Good luck.

Regards,
Erwin Moller

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация