|
Posted by Jim Michaels on 02/06/06 05:35
"Iain Napier" <emailaddressisinvalid@aol.com> wrote in message
news:XNednQLDfMJoGD7eRVnyuQ@pipex.net...
> alex wrote:
>>
>> Secondly, you can store the files outside of the webroot.. sounds like
>> you're using shared hosting here, so instead of putting the files in your
>> public_http, put them somewhere else, then your download script just
>> sources that file, whereever it is (fopen) and sends it..
>
> I've just realised I can change permissions on this server, so if I create
> a subdirectory in wwwroot called privatearea, put my file1.zip in there
> and remove the public read permission, a web browser can't get it's hands
> on it.
>
> Now, I create a test.php in the same directory as file1.zip and using
> $_SERVER['PATH_TRANSLATED'], I get the full file system path to where my
> files are. So:
>
> $file="/full/path/to/my/wwwroot/privatearea/file1.zip"
> if ($file_handle=fopen($file,"r")) echo("PHP can read the file!");
>
> And I see PHP can read the file okay, but web browsers don't get direct
> access to it.
>
> Presumably I can now use fopen to send the data back via PHP?
a better function might be readfile() because it reads the file and outputs
straight to the browser. all you need before it is header()s.
>
> Thanks for the pointer in your first post, I seem to be on the right track
> now I hope. Tomorrow I'll try and work out how to have PHP send the file
> back.. 3.30 am now :-\
[Back to original message]
|