मैंने PHP में एक फ़ाइल डाउनलोड स्क्रिप्ट बनाई है, यह काम करता है, लेकिन वेब ब्राउज़र फ़ाइल को "अज्ञात लंबाई" के रूप में रिपोर्ट करते हैं। मेरा कोड निम्नानुसार है:PHP डाउनलोड स्क्रिप्ट के साथ सही फ़ाइल आकार भेजना
function downloadFile($file){
// Set up the download system...
header('Content-Description: File Transfer');
header('Content-Type: '.mime_content_type($file));
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.filesize($file));
// Flush the cache
ob_clean();
flush();
// Send file to browser
readfile($file);
// DO NOT DO ANYTHING AFTER FILE DOWNLOAD
exit;
}
दिलचस्प। मुझे उसमें देखना होगा। –
धन्यवाद, मुझे अपने डाउनलोड में "gzip" सामग्री प्रकार मिल रहा था और इसे आपकी एचटीएसीएएस लाइन से छुटकारा पाने में सक्षम था, अब मैं डाउनलोड प्रगति को फिर से देख सकता हूं क्योंकि ब्राउज़र द्वारा कुल फ़ाइल आकार सही ढंग से पढ़ा जाता है। – adrianTNT