Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Upload files via socket che richiede troppo tempo

    Salve, sto utilizzando uno script preso da php.net per fare l'upload di un file via socket...
    Il problema è che quando il file è abbastanza grosso lo script richiede tantissimo tempo a creare gli headers!
    Ho fatto alcuni test e la lunghezza dell'header arrivava ad essere anche lunga 4 MILIONI di caretteri!!! Varia a seconda del peso del file da uploadare...
    Come posso risolvere?
    Questo è il codice che uso:
    Codice PHP:
            $remote_url "/cgi-bin/prova.cgi";
            
    $remote_server "localhost";
           
    // get the necessary data
           
    $file_name $_FILES['upfile']['name'];    // the file
           
    $tmp_name $_FILES['upfile']['tmp_name'];    // the file
           
    $content_type $_FILES['upfile']['type'];    // the file mime type
           
           
    srand((double)microtime()*1000000);
           
    $boundary "---------------------".substr(md5(rand(0,32000)),0,10);
           
           
    // Build the header
           
    $header "POST $remote_url HTTP/1.0\r\n";
           
    $header .= "Host: $remote_server\r\n";
           
    $header .= "Content-type: multipart/form-data, boundary=$boundary\r\n";
           
    // attach post vars
           
    foreach($_POST AS $index => $value){
               
    $data .="--$boundary\r\n";
               
    $data .= "Content-Disposition: form-data; name=\"".$index."\"\r\n";
               
    $data .= "\r\n".$value."\r\n";
               
    $data .="--$boundary\r\n";
           }
           

           
           
    // and attach the file
           
    $data .= "--$boundary\r\n";
           
    $data .="Content-Disposition: form-data; name=\"upfile\"; filename=\"$file_name\"\r\n";
           
    $data .= "Content-Type: $content_type\r\n\r\n";
           
    $data .= "".implode(""file($tmp_name))."\r\n";
           
    $data .="--$boundary--\r\n";
           
    $header .= "Content-length: " strlen($data) . "\r\n\r\n";
                     
    // Open the connection
            
    $header.=$data;
                     
           
    $fp fsockopen($remote_server80);
           
    fputs($fp$header);
           
    fclose($fp); 
    What is the |\/|atrix?

  2. #2
    up..
    What is the |\/|atrix?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.