Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
curl file upload and progress bar

I have a curl request to upload file and I want to show the progress. In progress function I am trying to run javascript, but javascript code isn't getting executed.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'some url');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'progress'));
curl_setopt($ch, CURLOPT_NOPROGRESS, false); // needed to make progress function work
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => $data));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$out = curl_exec($ch);

public function progress($resource,$download_size, $downloaded, $upload_size, $uploaded)
{
    $percentage = 0;
    if($download_size > 0)
        $percentage = $downloaded / $download_size  * 100;
    if($upload_size > 0)
        $percentage = $uploaded / $upload_size  * 100;
    $percentage = floor($percentage);
    echo "<script>alert('asdas')</script>;"; // <----not executing
}

The alert is not executing, what could be the reason ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!