Php Script for downloading files

sanjanaa - June 29, 2009 - 12:10

Hi, I want Php script to download files.

Thanks in advance,
Revathy.

What are you trying to do?

nevets - June 29, 2009 - 13:15

What are you trying to do? Core comes with the upload module and if using CCK there is the filefield module.

File Download

sanjanaa - June 30, 2009 - 04:04

Thank you for your reply nevets.

I uploaded my files into server through FTP. I used this php code to download that file.

<?php
$file
="pactus.zip";
header("Content-type: application/octet-stream");
header("Content-Type: application/zip");
header("Content-Type: application/jpg");
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"$file\"");
header("Content-Transfer-Encoding: binary");
readfile("pactus.zip");
?>

Using this code, I can able to download upto 4MB size files only. If my download exceed 4MB files, it downloads that file and if i tried to open the file it shows some error and it could not be opened.

For example:

1) If I download pdf files, then it shows while opening it,

"There was an error opening this document. The file is damaged and could not be repaired"

2) If I download zipped file, then it shows
"No archives to extract".

How can I solve this problem?

Thanks,
Revathy.

check the file size after

mm167 - June 30, 2009 - 04:26

check the file size after download. I guess u haven't successfully downloaded the whole file due to memory issue.

u may need a professional readfile() function (then the FREE readfile()) to handle large files.

good day.

We go the drupal way. How about you?
http://www.drupalway.com

Thank you mm. Yes my download

sanjanaa - June 30, 2009 - 05:03

Thank you mm. Yes my download file size is very small than the whole file. Ya i doesn't download fully. But I don't know what is professional readfile(). Can you please give any reference link for that?

Thanks,
Revathy.

 
 

Drupal is a registered trademark of Dries Buytaert.