Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda