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

  • Home
  • SEARCH
  • 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 6805383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:34:47+00:00 2026-05-26T19:34:47+00:00

I’m building a forum that will allow users to upload images. Images will be

  • 0

I’m building a forum that will allow users to upload images. Images will be stored on my web server temporarily (so I can upload them with a progress bar) before being moved to an S3 bucket. I haven’t figured out a brilliant way of doing this, but I think the following makes sense:

  1. Upload image(s) to the web server using XHR with progress bar
  2. Wait for user to submit his post
  3. Unlink images he did not end up including in his post
  4. Call a URL that uploads the remaining images to S3 (and update image URLs in post body when done)
  5. Redirect user to his post in the topic

Now, since step 4 can take a considerable amount of time, I’m looking for a cron like solution, where I can call the S3 upload script in the background and not have the user wait for it to complete.

Ideally, I’m looking for a solution that allows me to request a URL within my framework and pass some image id’s in the query, i.e.:

http://mysite.com/utils/move-to-s3/?images=1,2,3

Can I use a cURL for this purpose? Or if it has to be exec(), can I still have it execute a URL (wget?) instead of a PHP script (php-cli)?

Thanks a heap!

  • 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-26T19:34:48+00:00Added an answer on May 26, 2026 at 7:34 pm

    I found the solution to this problem which I’m happy to share. I actually found it on SO, but it needed some tweaking. Here goes:

    1. The solution requires either exec() or shell_exec(). It doesn’t really matter which one you use, since all output will be discarded anyway. I chose exec().

    2. Since I am using MAMP, rather than a system-level PHP install, I needed to point to the PHP binary inside the MAMP package. (This actually made a difference.) I decided to define this path in a constant named PHP_BIN, so I can set a different path for local and live environments. In this case:

      define(PHP_BIN, '/Applications/MAMP/bin/php/php5.3.6/bin/php');

    3. Ideally, I wanted to execute a script inside my web framework instead of some isolated shell script. I wrote a wrapper script that accepts a URL as an argument and named it my_curl.php:

      if(isset($argv[1]))
      {
          $url = $argv[1];
      
          if(preg_match('/^http(s)?:\/\//', $url))
          {
              $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, $url);
              curl_setopt($ch, CURLOPT_HEADER, 0);
              curl_exec($ch);
              curl_close($ch);
          }
      }
      
    4. In this SO question I found the way to execute a shell command in the background. This is necessary because I don’t want the user to have to wait until it’s finished.

    5. Finally, I run this bit of PHP code to execute the other (or ANY) web request in the background:

      exec(PHP_BIN . ' /path/to/my_curl.php http://site.com/url/to/request
      &> /dev/null &');
      

    Works like a charm! Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.