Running audio in php

Asked

Viewed 284 times

0

How is it possible to upload an audio tag with the file outside of my server

<audio controls>
  <source src="../../spool/teste.mp3" type="audio/mp3">
</audio>

On the same level as my www folder I have a folder called musicas, where there are the songs I want to play. I can use a file_exists to know if I have access and I can also unlink, but I can’t click src. How can I do this? also not possible if I pass the exact path C:/wamp/Music/test.mp3

1 answer

0


You cannot access files outside the directory www of the Web server. This is also for security reasons.

Either you should copy the files you want to share into this directory or, in the Web server settings, change the root directory. With XAMPP, for example, in the file httpd.conf configuration is on the line:

DocumentRoot "C:/xampp/htdocs"
  • Does this work the same way for linux as well? for example it is possible to set the folder C: as root directory so you can have access to all the files?

  • Works, on Linux you could set your folder /home/brunosilva/music for example as server root. But look at the issue of user that runs the web server. It has to somehow be allowed to read these directories/files. Assuming that the user running the service was, say,, www-data, or your directories and subdirs have to allow this user to read them (because they would belong to the brunosilva) or has to allow reading to all (which is a possible security breach).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.