473,395 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

filesize() problem

ganesanji
hi all,

I have created a simple downloading script for a file which is given below[php]$f="images/52219-4.bmp";
$ftype = mime_content_type($f);
$fsize= filesize($f);
header("Content-type: \"".$ftype."\"");
header("Content-Disposition: attachment; filename=\"".$f."\"");
header("Content-length:".$fsize);
readfile($f);
exit;[/php] Even this script downloads the image, the downloaded file size is 0 bytes.

What is wrong in this script or i have to add any more headers?
Plz anybody help me....
I am looking forward for your valuable suggestions and solutions.....

Advance thanks,
Apr 23 '08 #1
3 2607
ronverdonk
4,258 Expert 4TB
WARNING:
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Apr 24 '08 #2
TheServant
1,168 Expert 1GB
hi all,

I have created a simple downloading script for a file which is given below[php]$f="images/52219-4.bmp";
$ftype = mime_content_type($f);
$fsize= filesize($f);
header("Content-type: \"".$ftype."\"");
header("Content-Disposition: attachment; filename=\"".$f."\"");
header("Content-length:".$fsize);
readfile($f);
exit;[/php] Even this script downloads the image, the downloaded file size is 0 bytes.

What is wrong in this script or i have to add any more headers?
Plz anybody help me....
I am looking forward for your valuable suggestions and solutions.....

Advance thanks,

Never used fsize, but have you tried echoing $fsize and seeing if it is the headers or the use of the function?
Apr 27 '08 #3
ronverdonk
4,258 Expert 4TB
I can see no immediate problem. I have tried this code on my own system and it downloads my .bmp entirely, except for the funny name that is generated by default. That is because you have the path name as part of the output file name in your header and it will not accept the forward slash. But besides that, it is fine.

Ronald
Apr 27 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Powell | last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS foreach (array('mime', 'state', 'country') as $val) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);...
6
by: John | last post by:
Hi all, I'd like to evaluate dynamicaly the size of a dynamic file. I use the filesize() function... this is my code : $my_size =...
4
by: Marek Möhling | last post by:
My server (Apache/1.3.28 - PHP/4.3.3) is configured to receive gzipped data via: Header append Accept-Encoding "gzip, deflate" PHP is configured to send gzipped data via: php_value...
3
by: steve.burgess | last post by:
Hi - I need to extract the filesize from some files on the webserver. The directory structure is like this Root - Public_html - Downloads - Includes All the files I want the size of are...
2
by: IWP506 | last post by:
I just CANNOT figure out what is wrong with this! ------ $op1f = fopen("./test.txt","r"); $op1 = fread($op1f, filesize($op1f)); ------
4
by: Ken | last post by:
I would like to measure the fileSize of the image (without uploading it - php). I use: var size_pic = document.getElementById('num1').childNodes.fileSize; alert("size = " + size_pic); which...
3
by: Arjen | last post by:
Hello, When I have read a file with x.xxx.xxx.xxx bytes it is sometimes handy to show it in an diverent format than bytes. Is there a handy way to do this? Or is there a function for it? ...
4
by: DurumDara | last post by:
Hi ! I get the file datas with FindFilesW. I want to calc the filesize from nFileSizeLow and nFileSizeHigh with easiest as possible, without again calling os.getsize(). How to I do it ? I need...
3
by: mosscliffe | last post by:
I get a list of filenames from a directory with the following code, but I can not work out how to get the filesize of the filename I have just found. I guess it is fileinfo.length, but I can not...
2
by: Eric Layman | last post by:
I have checked this setting in my php.ini allow_url_fopen = On It is ON be default. According to the PHP documentation: it stated that as of php5, filesize supports the reading of remote...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.