Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs \Inovasi\get_fi le.php:2) in C:\xampp\htdocs \Inovasi\get_fi le.php on line 40
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs \Inovasi\get_fi le.php:2) in C:\xampp\htdocs \Inovasi\get_fi le.php on line 41
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs \Inovasi\get_fi le.php:2) in C:\xampp\htdocs \Inovasi\get_fi le.php on line 42
╨╧рб▒с������� ��������� >��■ ������������� ��V����������Y ������■ ���� U��� ье┴�[А ��°┐������0�� �����╖ ���bjbjм·м·��� ��������� ������ �4R��╬Р�╬Р� ╖
when I try to download the file, the above errors occur.I try to fix it but still got errors.Can you please help me...
11 2341 Markus 6,050
Recognized Expert Expert
This post was separated from Atli's post on Uploading to a MySQL database.
Let's have a gander at the file causing the issue. You have sent output to the browser, through one way or another, and, well, you cannot do this.
- mark
thanks for the explaination..
but, what should i do now??
is there any suggestion??
Markus 6,050
Recognized Expert Expert @ririe
Like I said previously: post the sourcecode of the file that is causing the error. We are not psychic, so it would help to see the file.
sorry..this is the code...hope u can help me - <?php
-
# Connect to the database
-
$dbLink = mysqli_connect("localhost", "root", "", "inovasi");
-
if(mysqli_connect_errno()) {
-
die("MySQL connection failed: ". mysqli_connect_error());
-
}
-
-
# Query for a list of all existing files
-
$result = mysqli_query($dbLink, "SELECT FileID, FileName, FileMime, FileSize, Created FROM FileStorage");
-
-
# Check if it was successfull
-
if($result)
-
{
-
-
# Make sure there are some files in there
-
if(mysqli_num_rows($result) == 0) {
-
echo "<p>There are no files in the database</p>";
-
}
-
else
-
{
-
# Print the top of a table
-
echo "<table width='100%' border='1'><tr>";
-
echo "<td><b>Name</b></td>";
-
echo "<td><b>Mime</b></td>";
-
echo "<td><b>Size (bytes)</b></td>";
-
echo "<td><b>Created</b></td>";
-
echo "<td><b> </b></td>";
-
echo "</tr>";
-
-
# Print each file
-
while($row = mysqli_fetch_assoc($result))
-
{
-
# Print file info
-
echo "<tr><td>". $row['FileName']. "</td>";
-
echo "<td>". $row['FileMime']. "</td>";
-
echo "<td>". $row['FileSize']. "</td>";
-
echo "<td>". $row['Created']. "</td>";
-
-
# Print download link
-
echo "<td><a href='get_file.php?id=". $row['FileID'] ."'>Download</a></td>";
-
echo "</tr>";
-
}
-
-
# Close table
-
echo "</table>";
-
}
-
-
# Free the result
-
mysqli_free_result($result);
-
}
-
else
-
{
-
echo "Error! SQL query failed:";
-
echo "<pre>". $dbLink->error ."</pre>";
-
}
-
-
# Close the mysql connection
-
mysqli_close($dbLink);
-
?>
Dormilich 8,658
Recognized Expert Moderator Expert
what's the code in get_file.php (where the error occurs)?
- <?php
-
# Make sure an ID was passed
-
if(isset($_GET['id']))
-
{
-
# Get the ID
-
$id = $_GET['id'];
-
-
# Make sure the ID is in fact a valid ID
-
if(!is_numeric($id) || ($id <= 0)) {
-
die("The ID is invalid!");
-
}
-
-
# Connect to the database
-
$dbLink = mysqli_connect("localhost", "root", "", "inovasi");
-
if(mysqli_connect_errno()) {
-
die("MySQL connection failed: ". mysqli_connect_error());
-
}
-
-
# Fetch the file information
-
$query = "
-
SELECT FileType, FileName, FileSize, FileData
-
FROM fileStorage
-
WHERE FileID = {$id}";
-
-
$result = @mysqli_query($dbLink, $query)
-
or die("Error! Query failed: <pre>". mysqli_error($dbLink) ."</pre>");
-
-
# Make sure the result is valid
-
if(mysqli_num_rows($result) == 1)
-
{
-
# Get the row
-
$row = mysqli_fetch_assoc($result);
-
-
# Print headers
-
header("Content-Type: ". $row['FileType']);
-
header("Content-Length: ". $row['FileSize']);
-
header("Content-Disposition: attachment; filename=". $row['FileName']);
-
-
# Print data
-
echo $row['FileData'];
-
}
-
else
-
{
-
echo "Error! No image exists with that ID.";
-
}
-
-
# Free the mysqli resources
-
@mysqli_free_result($result);
-
@mysqli_close($dbLink);
-
-
}
-
else
-
{
-
echo "Error! No ID was passed.";
-
}
-
?>
This is the code for get_file.php. When i try to download the file, it says that the errors come from the header part.Hope u can help me.Thank you
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs \Inovasi\get_fi le.php:2) in C:\xampp\htdocs \Inovasi\get_fi le.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs \Inovasi\get_fi le.php:2) in C:\xampp\htdocs \Inovasi\get_fi le.php on line 37
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs \Inovasi\get_fi le.php:2) in C:\xampp\htdocs \Inovasi\get_fi le.php on line 38
╨╧рб▒с������� ��������� >��■ ������������� ��V����������Y ������■ ���� U��� ье┴�[А ��°┐������0�� �����╖ ���bjbjм·м·��� ��������� ������ �4R��╬Р�╬Р� ╖������������� ��������������� �� ��������� ��������� � ��������������� �╖�����
This is the errors come out.I want to view the file first and then the user can download the file.How to do it??
Thank you
Dormilich 8,658
Recognized Expert Moderator Expert Markus 6,050
Recognized Expert Expert @Dormilich
The header() lines in his previous post.
It's strange, though, I don't see any output prior to those calls.
Make sure you have no whitespace before the opening <?php tag.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: David W. Fenton |
last post by:
I'm no stranger to this error message, but I have a client who is
experiencing it, but, fortunately, without any actual data
corruption, and it's driving them made. Their inability to grasp
that the cause is fundamentally a networking problem is also making
me pull my hair out.
Some history:
The network is composed of five computers dating back to 1995, each
purchased one at a time, and each having a different OS, etc. Until
|
by: Rhon Stewart via DotNetMonster.com |
last post by:
Hi please visit this link :
http://www.eggheadcafe.com/articles/pfc/selfupdater.asp
I followed all the steps for listed on the link , when I execute the
application it it gives me the following error on the log file:
---
ApplicationUpdateManager.StartUpdater] :
The Updater has started; the target application's name is 'SayHello'.
Time started: 2005_03_01_14:33:21.
|
by: Jocelyn Duhaylungsod |
last post by:
I have been getting the following server errors sporadically while
downloading excel, csv or xml file.
Internet Explorer cannot download <file name> from <IP address>
"The server returned an invalid or unrecognized response" /
"The connection with the server was reset"
I'm using Response.BinaryWrite to send down the file content as attachment
(sample codes is attached below). I read some of the similar posts in the
newsgroup about the...
|
by: Ramesh Dodamani |
last post by:
Environment:
XP Pro, VS.Net 2003, .Net 1.1.4322 with SP1 & KB Hotfix 886903
P4 2.2GHz, 1 GB RAM
My system was working fine till a few weeks back when I started seeing the
following errors.
"aspnet_wp.exe (PID: xxxx) stopped unexpectedly"
I am seeing the this error currently happen, but unlike the description in
articles Q823409 or 821387, I am not downloading any large file .The error
|
by: just.starting |
last post by:
Hi,
My dot net client downloads files and checks for any new files time to
time. The server is apache2.0.53 server. So what happens is that my
file download thing works fine if I dont try to call any page from the
server while downloading. If I try to call a single page while
downloading a file then the page request goes time out and the server
then closes the existing download stream and the client doestn't throw
any exception. So many a...
| |
by: Tomas Martinez |
last post by:
Hi there!
I'm trying to download a file in my asp.net web, but when downloading it
from a Firefox browser, instead of downloading the example.exe file, it's
downloading example.exe.htm. My code is the following:
string localfile = MyComponent.DownloadMyExe(index);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType="application/octet-stream";
|
by: ruju00 |
last post by:
I am getting an error in Login() method of the following class
FtpConnection
public class FtpConnection
{
public class FtpException : Exception
{
public FtpException(string message) : base(message){}
public FtpException(string message, Exception innerException) :
base(message,innerException){}
|
by: C. Feldmann |
last post by:
Hello,
I have stumbled upon a problem, for which I canТt seem to find a
solution for. I would like to offer files for downloading. To allow
files to have duplicate names I renamed as random alphanumeric-
strings. With the header command I can give them their Уold nameФ back
just before downloading. Then use readfile or loop through feof/echo
fread to push the fileТs contents. This works well.
The amount of files has increased, so that...
|
by: JRough |
last post by:
What is the purpose of caching in the header below? I used
something like this for downloading a detail page to Excel but in this
example it looks like it is for cache control? Why would you expire a
header? So the user couldn't send a request after too long of a period
for example in the downloaded excel page?
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the
past
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deploymentЧwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |