CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 downloading files

Print topic Send  topic

Author Message
kirchaj
Posted: 04/08/2004, 2:29 PM

I have been able to get a simple file upload to work but would like to be able to download the files that have been uploaded. Any ideas on how to do this? I have looked but haven't found any info... Thanks.

Tony
peterr


Posts: 5971
Posted: 04/08/2004, 2:43 PM

Hi,

Once the files are uploaded, the path to each file is stored in the database field that you specified as "Control Source" for your FileUpload component.
You can create a link (using the Link component from the Toolbox) and use the same "Control Source". Then the link will point to the file and users can click on it to download the file.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
JCF
Posted: 04/08/2004, 6:25 PM

This is the code I use:

<?php
define("RelativePath", ".");
include(RelativePath . "/Common.php");

$file = CCGetParam("file", "");
$size = CCGetParam("size", "");
$doc_id = CCGetParam("doc_id", "");

$file_name = substr (strrchr ($file, "/"), 1);
$file_name = substr (strstr ($file_name, "."), 1);

//$size = filesize($file);
header("Content-length: $size");
header("Content-Type: application/unknown");
header("Content-Disposition: attachment; filename=\"$file_name\"");
header("Content-Transfer-Encoding: binary");
readfile($file);

$db = new clsDBAdelphosweb();
$SQL = "UPDATE web_docs SET cnt = cnt + 1 WHERE doc_id=" . $doc_id;
$db->query($SQL);
$db->close();

exit();
?>

I put this in one file and download.php

Then I call the file like this:

$web_docs->Link1->Page = "download.php?file=/home/3829249850/www/web/docs/"
.. $web_docs->FileUpload1->Value . "&size=" .
$web_docs->FileUpload1->GetFileSize() . "&doc_id=" .
$web_docs->doc_id->GetValue();

Hope this helps
gameon

Posts: 10
Posted: 06/07/2004, 9:16 PM

In using Peterr' slink suggestion above, I cannot get the link to download the file from the proper folder. Th efile folder is specified in the File Upload component, however. file is saved in the database without the file folder.

Soooo the question is how do I get the link to retrieve the uploaded file? I have tried to add the file folder in the Befroe show event, however, i am not suceesful.

Any ideas are appreciated.
View profile  Send private message
gameon

Posts: 10
Posted: 06/08/2004, 11:27 AM

fixed this by editing the href html code...
View profile  Send private message
NickM

Posts: 44
Posted: 06/08/2004, 10:18 PM

Just another spin on this question:
How do you view the uploaded file (instead of linking and downloading it). Assuming it is plain text or HTML file (not an image).
View profile  Send private message
geee
Posted: 07/02/2004, 4:37 AM

Quote kirchaj:
I have been able to get a simple file upload to work but would like to be able to download the files that have been uploaded. Any ideas on how to do this? I have looked but haven't found any info... Thanks.

Tony
Nobody
Posted: 09/18/2004, 10:31 PM

JCF, what would happen if I did this kind of thing to your site?

download.php?file=/etc/password
download.php?file=/etc/shadow
feha


Posts: 712
Posted: 09/22/2004, 10:34 AM

Quote Nobody:
JCF, what would happen if I did this kind of thing to your site?

download.php?file=/etc/password
download.php?file=/etc/shadow

the risk can be eliminated by using file name only ...
$file = CCGetParam("file", "");
as
$file="/downloads/".CCGetParam("file", "");
if(file_exists($file))
{
........
}

;-)


;-)
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message
klw
Posted: 09/22/2004, 10:38 AM

You'll need to prefix the Control Source value (from Peterr's posting)
with the value you used for the File Folder property of the File Upload.

Quote gameon:
In using Peterr' slink suggestion above, I cannot get the link to download the file from the proper folder. Th efile folder is specified in the File Upload component, however. file is saved in the database without the file folder.

Soooo the question is how do I get the link to retrieve the uploaded file? I have tried to add the file folder in the Befroe show event, however, i am not suceesful.

Any ideas are appreciated.
diligentman

Posts: 7
Posted: 11/11/2004, 8:22 PM

Quote :
You'll need to prefix the Control Source value (from Peterr's posting) with the value you used for the File Folder property of the File Upload.

It would be good and most valuable if you would show how to do this prefixing, exactly. Because of your help, I know what to do, but not How to do it. ;-)

And CodeCharge, this needs to be documented properly within the context and content of the excellent Upload Overview in the help. One almost never wants to upload with out being able to download In future versions, the upload and download capability should, in my opine be combined with download being transparent and built in with the upload. Putting navigators on the file location fields of the upload file object would be most helpful too. :-<

Thanks klw, for stepping in and helping.
_________________
DiligentMan,
Northern Colorado
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.