473,396 Members | 1,924 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,396 software developers and data experts.

this downloading code is giving an error "warning filesize() expects string"

2
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     if(isset($_GET["notesid"]))
  3.     {
  4.         $notesid = $_GET["notesid"];
  5.         include("dbcon.php");
  6.         $con = mysql_connect(SERVERNAME,USERNAME,PASSWORD);
  7.         mysql_select_db(DBNAME,$con);
  8.         $query = "select notesid,filename,filesize,filetype,fileextname from notesinfo where notesid=$notesid";
  9.         $result = mysql_query($query,$con);
  10.         if($result && mysql_num_rows($result)>0)
  11.         {
  12.             $row = mysql_fetch_array($result);
  13.             $path ="upload/" . $row[0] . "." . $row[4];
  14.             $file = fopen($path,"r");
  15.             clearstatcache();
  16.             $content = fread($file, filesize($file));
  17.             header("Content-Type:" . $row[3]);
  18.             header("Content-length:". $row[2]);
  19.             header("Content-Disposition: attachment; filename=" . $row[1]);
  20.             echo $content;
  21.             fclose($file);
  22.         }
  23.         mysql_close($con);
  24.     }
  25. ?>
Jul 24 '14 #1
1 1235
Rabbit
12,516 Expert Mod 8TB
The filesize function expects a string that represents the path to the file, not a file object.
Jul 24 '14 #2

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

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
10
by: Lakshmi Narayanan.R | last post by:
Hi Experts, Using keyword "To" in select case giving error.The following code is got from www.microsrosoft.com itself. What is the wrong with this?. <% Dim Number1 Number1 = 7 ' Initialize...
4
by: Max Harvey | last post by:
Hi, I have looked at the example called "Open Parameter queries from code" from the site http://www.mvps.org/access/queries/qry0003.htm I made up a test which I though looked pretty close...
0
by: Santosh | last post by:
Hii, I am developing web application using asp.net with in that i am using crytal report for showing reports. it works fine on local machine but when i deploy it on the web server it gives me key...
1
by: Paulson | last post by:
Hi all I got a problem in my PHP code while uploading huge files The error is as follows __________________________________________________________________ $_FILE -...
5
by: mike3 | last post by:
Hi. Is this a good idea?: <begin code> /* Addition operator: += */ const BigFix &BigFix::operator+=(const BigFix &rhs) { ErrorType err; int lhs_sign = sign, rhs_sign = rhs.sign;
1
by: Rahul Bhate | last post by:
Hello Sir My problem is in dos giving error that javac is not recognised.Tell me the steps for debugging.I have already set the CLASSPTH through command line & also set the PATH.But still giving...
4
by: mukeshrasm | last post by:
<?php // create new document pdf_new(); $pdf = pdf_new(); pdf_open_file($pdf); pdf_begin_page($pdf, 500, 700); // define a font $font = pdf_findfont($pdf, "Courier", "host", 0);
6
by: dragiton | last post by:
ASP Code Redirect Error Hello I recently relaunched a website containing asp code which used to work perfectly. However, after resetting up the SQL DB and trying to work out some site bugs I have...
7
gskoli
by: gskoli | last post by:
Error - working in IE and MOzilla but giving error null or not a object: Guys i am giving you snippet of code , where it is javascript digital clock , It is showing time and working properly but...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.