Member Avatar for Dilbert137

Dear All,

I'm searching a code which allow the user to download directly a file from the php web page. Has anyone knows how to do it? It seems to be a simple coding.

Regards
Dilbert137

Do you mean like this?

<?php
echo '<xmp>'; //show pure html instead of styling
echo file_get_contents('http://www.daniweb.com/');
echo '</xmp>';
?>
Member Avatar for Dilbert137

Dear Sir,

I have tried your script but i'm getting errors.

[<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in

Regards
Dilbert137

That means the file does not exist. If you wish not to see the error an alternative would be curl.

Member Avatar for Dilbert137

Yes you are right i'm putting the domain name when i was doing test on my pc.

Thanks a lot
Dilbert137

Member Avatar for Dilbert137

Thanks very much. It was exactly what i was searching for.

Thanks again
Dilbert137

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.