Howdy!
My application needs to store just a couple of files, so I'd rather not go the route of integrating BOX- I'd prefer just to allow the user to upload a file, store it as a blob in MySQL, then allow the user to download it later.
I've got the upload set up just fine.
I understand this content and can use it to display the NAME of the uploaded file...
http://wiki.nubuilder.com/tiki-index.ph ... uilderDocs
...but I'm still wrestling with how to generate a link to allow the user to download the file. Any guidance available?
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Download link for PDF stored as blob
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: Download link for PDF stored as blob
mlgeek ,
- 1) add a text object on your form that shows the file name (when the record is saved): - 2) to open the file object called xyz you can insert this code in On Double Click field of the text object:
- 3) in Setup > Add Activity add a showDoc procedure that select and show the file:
Hope this helps.
Max
- 1) add a text object on your form that shows the file name (when the record is saved): - 2) to open the file object called xyz you can insert this code in On Double Click field of the text object:
Code: Select all
var docName = $('#xyz_file_name').val();
if (docName != '') {
runIt('showDoc', docName);
}
Code: Select all
/* Get record from db using parameter passed through runIt() via a hash id */
$par = '#runIt1#';
$sql = "SELECT * FROM your_table WHERE xyz_file_name = '" .$par. "'";
$fileObj = db_fetch_object(nuRunQuery($sql));
$file = $fileObj->xyz;
$fileName = $fileObj->xyz_file_name;
$fileType = $fileObj->xyz_file_type;
header("Content-type: ".$fileType);
header("Content-Disposition: attachment; filename=".$fileName);
header("Pragma: private");
header("Cache-control: private, must-revalidate");
/* show the file */
echo $file;
Max
You do not have the required permissions to view the files attached to this post.
-
- Posts: 23
- Joined: Tue May 08, 2012 8:24 pm