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

download file problem

hi all,

i have face this problem more 3 days.. if anybody help me..

i have upload file through php coding .. i have download that same file from server..
its coming empty file.. i dont know why its coming... its correctly working in local system.. but not working server. Linux server
its very urgent.. pls reply me.
[php]
Its Upload coding:
--------------------------
<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES["attachment"]["name"]);

if(move_uploaded_file($_FILES["attachment"]["tmp_name"], $target_path)) {
echo "The file ". basename( $_FILES["attachment"]["name"]).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>[/php]
Its download coding :[php]
<?php
ob_start();
$dirfile=$_REQUEST['file'];
$file=basename($dirfile);
$dir = "../uploads/";
if ((isset($file))&&(file_exists($dirfile))) {
header("Content-type: application/force-download");
header('Content-Disposition: inline; filename="' . $dirfile . '"');
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($dirfile));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $dirfile . '"');
readfile("$dirfile");

} else {
echo "No file selected";
}
?>[/php]--------------------------
by
Karthik
Mar 3 '08 #1
2 1257
ronverdonk
4,258 Expert 4TB
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
Mar 3 '08 #2
Markus
6,050 Expert 4TB
Do you not have to give the right content type?
ie. image/jpeg application/pdf
Mar 3 '08 #3

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

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
3
by: Brent Billups | last post by:
I am trying to download files from one website to another for purposes of caching. In trying to do this, I created a VB dll component (using VB6), that used URLDownloadToFile, to allow me to...
14
by: James Wong | last post by:
Hi! everybody, I'm facing a quite strange download problem. I use the following code to download an XML file to client side: With Response ' clear buffer Call .Clear() ' specify the...
4
by: hoenes1 | last post by:
Hi, in my ASP.NET App, I have a list of files which the user can download on click (using Response.BinaryWrite()). the problem is, that once a download has started, the user can't navigate in...
1
by: Al | last post by:
Hi! I try to use custom download page (download.aspx) wich writes file (about 700Mb) to response. But I can download only one file from one IP at the same time. I think that this is IIS or...
2
by: Ken Varn | last post by:
I have an ASP.NET page that incorporates the following code on a button press. private void DownloadTag_Command(object sender, CommandEventArgs e) { FileStream fs; String Filename; Filename...
5
by: Bala | last post by:
Hi I displaying my pdf files ( F:\test\test1\test.pdf - for example file path) on datagrid for user download. when I right clik the link and its show like this file:///F:/test/test1/test.pdf....
1
by: a.r.austin | last post by:
Hello, I am trying to download a few files one after another from a remote server. Problem is that I don't know how to, or if I am able at all, set a time out for download. I don't want to time...
3
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. ...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
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: 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?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.