downloading binary files ussing mime and tcpconnect
This WebDNA talk-list message is from 2004
It keeps the original formatting.
numero = 60374
interpreted = N
texte = Hello people.I just want a little help :) on the use of tcpconnect / tcpsend.Im trying to obtain files in binary mode, on the same server, and show thedownload window on the user side....What im ussing is, this code..[showif [findstring source=[platform]&find=Windows]>0] [text]hostname=[GETMIMEHEADER name=HTTP_HOST][/text][/showif][hideif [findstring source=[platform]&find=Windows]>0] [text]hostname=[GETMIMEHEADER name=HOST][/text][/hideif][text]path=[middle starafter=&endbefore=download][thisurl][/middle][/text][text]crlf=[unurl]%0D%0A[/unurl][/text][fileinfo file=[path][folderpath][selfilename]] [text]filesize=[size][/text][/fileinfo][setmimeheader name=Content-type&value=application/octet-stream][setmimeheader name=Content-ID&value=[selfilename]][setmimeheader name=Content-transfer-encoding&value=binary][setmimeheader name=Content-length&value=[filesize]][setmimeheader name=Content-disposition&value=attachment;filename=[selfilename]][tcpconnect host=[hostname]&ssl=F][writefile file=[selfilename]][tcpsend skipheader=T]GET [path][folderpath]HTTP/1.0[crlf]host: [hostname][crlf][crlf][/tcpsend][/writefile][/tcpconnect]Ok, the the variables im passing to the script are for example:download.tpl?selfilename=theimage.jpg&folderpath=thefolder/oftheimages/At this point, the download window is shown as well, but im not receivinganythinng, just a blank thing with the name of the image. I have testedwithout writefile, i obtain more or less the file size, but corrupted data.I have tested with php, ussing this: $file = $_GET['selfilename']; $path = $_GET['folderpath'].$file; //force download dialog header("Content-type: application/octet-stream\n"); header("Content-ID: $file\n"); header("Content-transfer-encoding: binary\n"); header("Content-length: " .$_GET['filesize']."\n"); header("Content-disposition: attachment; filename=\"$file\"\n"); //send file contents $fp=fopen($path, "r"); fpassthru($fp);?>And the file is downloading as well... But i need it working on webdna :)I know php can read binary files and webdna can't, but i was thinking maybeussing tcpconnect i can obtain the binaryfile content? i try to find how onthe webdna talk list and i just find something about a corrected bug on theversion 5, i saw theres say that the tcpconenct buffers only acpet asciichars, but with these bugfix, you can use write file... but i have theversion 6 developer, and does not work.Maybe im doing something wrong?Thanks a lot!Roberto Antonio Berrospe MachinSenior Programer / Developer / Server-Lan ManagerVirtual Job Zone Corporation.New York - United Stateshttp://www.virtualjobzone.comrobert@virtualjobzone.comPhone: 1 - 718 576 2210Office Personal: 1 - 914 372 8133-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list
.To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Associated Messages, from the most recent to the oldest:
Hello people.I just want a little help :) on the use of tcpconnect / tcpsend.Im trying to obtain files in binary mode, on the same server, and show thedownload window on the user side....What im ussing is, this code..[showif [findstring source=[platform]&find=Windows]>0] [text]hostname=[GETMIMEHEADER name=HTTP_HOST][/text][/showif][hideif [findstring source=[platform]&find=Windows]>0] [text]hostname=[GETMIMEHEADER name=HOST][/text][/hideif][text]path=[middle starafter=&endbefore=download][thisurl][/middle][/text][text]crlf=[unurl]%0D%0A[/unurl][/text][fileinfo file=[path][folderpath][selfilename]] [text]filesize=[size][/text][/fileinfo][setmimeheader name=Content-type&value=application/octet-stream][setmimeheader name=Content-ID&value=[selfilename]][setmimeheader name=Content-transfer-encoding&value=binary][setmimeheader name=Content-length&value=[filesize]][setmimeheader name=Content-disposition&value=attachment;filename=[selfilename]][tcpconnect host=[hostname]&ssl=F][writefile file=[selfilename]][tcpsend skipheader=T]GET [path][folderpath]HTTP/1.0[crlf]host: [hostname][crlf][crlf][/tcpsend][/writefile][/tcpconnect]Ok, the the variables im passing to the script are for example:download.tpl?selfilename=theimage.jpg&folderpath=thefolder/oftheimages/At this point, the download window is shown as well, but im not receivinganythinng, just a blank thing with the name of the image. I have testedwithout writefile, i obtain more or less the file size, but corrupted data.I have tested with php, ussing this: $file = $_GET['selfilename']; $path = $_GET['folderpath'].$file; //force download dialog header("Content-type: application/octet-stream\n"); header("Content-ID: $file\n"); header("Content-transfer-encoding: binary\n"); header("Content-length: " .$_GET['filesize']."\n"); header("Content-disposition: attachment; filename=\"$file\"\n"); //send file contents $fp=fopen($path, "r"); fpassthru($fp);?>And the file is downloading as well... But i need it working on webdna :)I know php can read binary files and webdna can't, but i was thinking maybeussing tcpconnect i can obtain the binaryfile content? i try to find how onthe webdna Talk List and i just find something about a corrected bug on theversion 5, i saw theres say that the tcpconenct buffers only acpet asciichars, but with these bugfix, you can use write file... but i have theversion 6 developer, and does not work.Maybe im doing something wrong?Thanks a lot!Roberto Antonio Berrospe MachinSenior Programer / Developer / Server-Lan ManagerVirtual Job Zone Corporation.New York - United Stateshttp://www.virtualjobzone.comrobert@virtualjobzone.comPhone: 1 - 718 576 2210Office Personal: 1 - 914 372 8133-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
"Roberto A. Berrospe Machin"
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Zipcodes (1998)
WebCat cannot handle compatible search parameters? (1997)
WebCommerce: Folder organization ? (1997)
Re:quit command on NT (1997)
No Access warning when caching HTML files (1997)
[WebDNA] feature suggestion (2011)
Moving records (2000)
WebCatalog 3.0.8 is on FTP... (2000)
Reversing [ipaddress] normalization (1998)
request for string functions (1998)
[WriteFile] problems (1997)
Include a big block of text (1997)
Template Encrypt Speed (1998)
Protecting webdelivery (1997)
Updating a database once per day - An example (1998)
WebCatb15 Mac CGI -- [purchase] (1997)
[LOOKUP] (1997)
Tracking System? (1997)
ImageMagick and [shell] (2003)
Initiating NewCart (1997)