Do for X amount of seconds ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anthony2oo5
    New Member
    • Jun 2007
    • 26

    Do for X amount of seconds ?

    Is it possible to have PHP do something for a certain amount of time, and if the time is reached for it to stop ?

    Basically I'm trying to allow a user to remotely upload a file, but if the file cannot be reached then for the script ti timeout with a custom error. I don't really want to use the setting in php.ini because I cant control the way that behaves.

    Any help would be appreciated.

    Thanks in advance.
  • Purple
    Recognized Expert Contributor
    • May 2007
    • 404

    #2
    Hi Anthony2oo5 and welcome to TSDN

    I wanted to clarify what you mean by remotely - are you asking if there is a way to timeout a user whilst they are browsing their local file system looking for a file to upload ?

    Purple

    Comment

    • Anthony2oo5
      New Member
      • Jun 2007
      • 26

      #3
      Thanks for your fast reply.

      Ok a user comes to the site and wants to upload a image to my site that is already hosted elsewhere. So rather them download the image to their machine, then upload it to my site, I want the to be able to directly port it over (Sort of like wget).

      But rather than my script trying to get a file that isnt there, and trying and trying, I want it to display a more friendly error rather than the (Script executed for more than 30 seconds message).

      So after the script trying to download a file fore more than 20 seconds I want it to stop and say, the script could not find anything.

      Hope this clears some things up for you.

      Thanks again.

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        I believe that if you use fopen(), it will fail after a certain amount of time. Likely you will be able to configure this on a page-by-page basis using ini_set().

        Comment

        • adamalton
          New Member
          • Feb 2007
          • 93

          #5
          You could *possibly* use the cURL functions if you have cURL enabled on your version of php. It lets you connect to other websites/webservers. It has lots of settings including timeout options, etc. I wont go into details, but search for "curl" in the manual at www.php.net.

          Comment

          Working...