Jump to content

Clarification: File Transfer


T-Bird

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.