0
<? header("Content-type: octet/stream"); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=a.mp3"); readfile("http://adstorage.jamba.net/storage/view/325/0/fa/Fairytale.mp3"); ?> 

This code is working great in my localhost but displays File not found when uploaded to my server

9
  • 2
    You have uploaded Fairytale.mp3 to /storage/view/325/0/fa ? Commented Nov 30, 2012 at 9:28
  • 2
    Then check for file permissions Commented Nov 30, 2012 at 9:29
  • else it wouldn't work in localhost too Commented Nov 30, 2012 at 9:30
  • i have uploaded this php file in another website. Commented Nov 30, 2012 at 9:30
  • i don't belong to adstorage.jamba.net Commented Nov 30, 2012 at 9:30

3 Answers 3

2

Do you have PHP permissions to read external files?

These permissions might be different on your local machine and the web server.

According to the readfile() documentation:

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Sign up to request clarification or add additional context in comments.

4 Comments

why would these permissions result in a 404? they'd just result in php errors, surely.
The OP states that he got a 'file not found issue', not a 404 HTTP response... You came with that one :)
Fair point, although he does say the screen displays 'File not found'. PHP protocol wrapper errors would be 'failed to open stream', 'Operation not permitted', etc..
Yes, that point is a bit unclear. The OP did not specify the exact error message (including line number if it is indeed a PHP error) or details about which mechanism (PHP, HTTP, ...) threw the error
0

*Please set the file permission so only it can be working correctly.. *

1 Comment

you checked the comment discussion?
0

I don't think the code you've posted has anything to do with the 404. A code error with your mp3 download would not produce a 404.

Chances are your CodeIgniter setup is wrong/different on your remote host. Check the routing is working. Do other controllers work?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.