473,383 Members | 1,980 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,383 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 1233
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: 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...

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.