Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1070281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:32:21+00:00 2026-05-16T20:32:21+00:00

I have written a pretty basic upload script that takes the file and uploads

  • 0

I have written a pretty basic upload script that takes the file and uploads it using the standard move_uploaded_file method as you see below:

//UPLOAD IMAGE
        $path = "../../clients/$realClient/" . $_FILES["image"]["name"][$x];
        move_uploaded_file($_FILES["image"]["tmp_name"][$x], $path);
        $displayPath = "private/clients/$realClient/" . $_FILES["image"]["name"][$x];       
        mysql_query("INSERT INTO images VALUES(NULL, '$displayPath', '$client', '$project', '$newWeight')") or die("Unable to Insert Image - Please Try Again");
        echo "File Successfully Uploaded<br />";

This upload script works perfectly for most purposes. Here’s my issue:

I have a standard shared hosting package so sometimes when the user tries to upload a file that takes over five minutes to upload (say a video or some other high res media), the server times out. The hosting company has said that as it’s a shared hosting server they are unwilling to increase the timeout limit for me.

Is there a more efficient upload script that will allow files to go up in under five minutes or is there perhaps an alternative you could suggest?

Cheers,
Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:32:21+00:00Added an answer on May 16, 2026 at 8:32 pm

    The PHP script is run after the upload completes; so if there’s a timeout during the upload, there’s nothing you can do in the script (as it won’t be run at all).

    If the timeout occurs during the script, you could split it into multiple parts – have the first script just store the uploaded file and HTTP redirect to another, which will do the processing and database work. In the script you’re showing, the processing seems simple enough, not sure if splitting that would help.

    Assuming you’re showing just a simplified version:

    script1.php

        // upload is complete
        $fname= basename($_FILES["image"]["name"][$x]); //prevent directory traversal
        $uniqid = uniqid("",true);
        $path = "../../clients/$realClient/temporary/" . $uniqid . '/' . $fname;
        // move to temporary location and redirect
        move_uploaded_file($_FILES["image"]["tmp_name"][$x], $path);
        header('Location: /script2.php?file=' . $uniqid . '/' . $fname);
    

    script2.php

        $path = $_GET['file'];
        $uniqid = basename(dirname($path));
        $fname = basename($path);
        $temp_path = "../../clients/$realClient/temporary/" . $uniqid . '/' . $fname;
        $final_path = "../../clients/$realClient/" . $fname;
        move($temp_path,$final_path);
    
        // do whatever processing is necessary
        mysql_query("INSERT INTO images VALUES(NULL, '$displayPath', '$client', '$project', '$newWeight')") or die("Unable to Insert Image - Please Try Again");
        echo "File Successfully Uploaded<br />";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty basic REST call that is written using node / express
I have written some code that works pretty well, but I have a strange
Summary I have written an Excel wrapper in .NET using Visual Basic and Visual
We have a front end written in Visual Basic 6.0 that calls several back
So I have a pretty simple UDF written in visual basic for use in
I have written a basic signalr hub that accepts a call from a client,
I have written something like this pretty easily in C# ( string GetUrl(new {
I have written a code and i'm pretty much stuck. In the following code,
I'm pretty new in C#. I have Dll written on C++ by myself and
I've written an entire app pretty successfully in Django but I have this nagging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.