By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,498 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,498 IT Pros & Developers. It's quick & easy.

download file problem

P: 2
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.
Its Upload coding:
$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!";
Its download coding :[php]
$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 . '"');

} else {
echo "No file selected";
Mar 3 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 4,258
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.

Mar 3 '08 #2

Expert 5K+
P: 6,050
Do you not have to give the right content type?
ie. image/jpeg application/pdf
Mar 3 '08 #3

Post your reply

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