View Single Post
ישן 07-11-08, 11:40   # 1
Ron | CSite.co.il
חבר על
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
גיל: 33
הודעות: 980

Ron | CSite.co.il לא מחובר  

php | הורדת קובץ

שלום,
יש לי בעיה קטנה בהורדת קובץ מהשרת אל המחשב בעזרת php.
אני מצליח להוריד את הקובץ בצורה מושלמת והכל,
הבעיה היחידה היא שצריך לחכות בעמוד ההורדה X זמן (בהתאם לגודל הקובץ),
אם מנסים להוריד קובץ של 14 מגה לדוגמא, צריך לחכות הרבה זמן עד שמופיע חלון ההורדה.
איך אפשר לעשות שזה יוריד ישר ?

הקוד:

PHP קוד:
    // fix for IE catching or PHP bug issue
    
header("Pragma: public");
    
header("Expires: 0"); // set expiration time
    
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    
// force download dialog
    
header("Content-Type: application/force-download");
    
header("Content-Type: application/octet-stream");
    
header("Content-Type: application/download");    
    
// use the Content-Disposition header to supply a recommended filename and
    // force the browser to display the save dialog.
    
header("Content-Disposition: attachment; filename=".basename($download_file).";");
    
header("Content-Transfer-Encoding: binary");
    
header("Content-Length: ".filesize($local_file));    

  
    
// open file stream
    
$file fopen($local_file"r");    
    while(!
feof($file)) {
        
// send the current file part to the browser
        
print fread($fileround($download_rate 1024));    
 
        
// flush the content to the browser
        
flush();
 
        
// sleep one second
        
sleep(1);    
    } 
לפי מה שבדקתי,
הבעיה היא שהקובץ עובר על הלולאה ורק אז מציג את חלון ההורדה (אחרי שהוא מסיים לעבור על כל הלולאה).

תודה רבה.
  Reply With Quote