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 ?