T-Bird Posted March 8, 2009 Share Posted March 8, 2009 I'm going to be transferring some files, most will be .zip but some may be .psd. To make sure (as best I can) that the files are saved and not opened I'm using the old octet-stream header trick. header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="<filename>"'); readfile("<Filename>"); From my very limited testing on my local servers it seems that readfile allows you to transfer files that are hosted on other servers - however I have been unable to do extensive testing on this due to limited resources. Is it the case that readfile is allowed to take files from external sources? Is this a dependable solution? In my case I'm building a site that will be hosted with a hosting service, but I would like to have a local machine at the office be a file server (also running PHP) where it's easy to upload all the files. Is there any reason I may not be aware of that would prevent the above code from working on the production site. Are there settings that I need to set to allow/disallow this kind of transfer. I'm still getting my feet wet with the file manipulation part of php. Thanks for the patience and the replies. Link to comment https://forums.phpfreaks.com/topic/148535-clarification-file-transfer/ Share on other sites More sharing options...
T-Bird Posted March 11, 2009 Author Share Posted March 11, 2009 I think I read in the rules that bumps were legal after 24 hours of inactivity. I hope so, cause I'm going to try one. Anyways, if I was unclear before (I have a knack for writing my messages late when I can't put my thoughts together clearly). I'll restate the question. I am trying to transfer a file from a local server, through the page on my public server run by Network Solutions, to the user. I did an (extremely) limited test which seemed to indicate that I could pull files from a remote server through an intermediary server to my browser via readfile(). This seems like it would be a security risk however and I wondered if there were any settings I would need to be aware of to allow such a transfer. Also, is there a PHP function better suited for such a transfer than readfile(). (in hind sight, this topic may fit in the server forum better than here in the PHP help forum. Sorry if I flubbed this one.) Link to comment https://forums.phpfreaks.com/topic/148535-clarification-file-transfer/#findComment-781825 Share on other sites More sharing options...
exally Posted March 11, 2009 Share Posted March 11, 2009 how big are the files? becuase i have just thought of a real shitty way to do it. Basically using CURL, request a php file on the local server to open it and print the file as the response. Then instead of read file, print or echo the CURL response. Shitty method i know, also look at FTP'ing to the new server on request. using the PHP FTP functions. Link to comment https://forums.phpfreaks.com/topic/148535-clarification-file-transfer/#findComment-781845 Share on other sites More sharing options...
T-Bird Posted March 12, 2009 Author Share Posted March 12, 2009 1-2 gig.... They are entire zipped psd plan files for large public buildings. I may talk them into breaking it into 5-6 smaller packets if downloads are too unbearable, but they would object. If I have to I have PHP installed on the office fileserver and I can point an A-name from a subdomain to that. But I'd like to isolate that server from the net so I can have an intranet page there without too much trouble validating users. Link to comment https://forums.phpfreaks.com/topic/148535-clarification-file-transfer/#findComment-782694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.