KoLi KoLi - 1 year ago 82
Javascript Question

Load files out from ROOT

I wanna create a folder, out of my ROOT dir. Called: 'karaoke'.

My ROOT dir is '/var/www/'.

If i try to load an .mp3 file from this 'karaoke' dir, it cannot find that.

I tried the following codes:

$( document ).ready(function(){ startFlash('','../karaoke/sample.mp3',''); });

$( document ).ready(function(){ startFlash('','/var/karaoke/sample.mp3',''); });

If the 'karaoke' dir is in the ROOT dir, the following code works:

$( document ).ready(function(){ startFlash('','karaoke/sample.mp3',''); });

I dont understand this situation. If anyone can help, pls write a solution.

Thank, KoLi

Answer Source

That's what the root is for! If any client could simply use ../ notation to break out of your web root, they could call ../../../etc/shadow or ../../apps/secretdatabase or whatever else.

If you want your apache server to be able to serve a directory outside the root, use an alias:


The Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot. URLs with a (%-decoded) path beginning with URL-path will be mapped to local files beginning with directory-path. The URL-path is case-sensitive, even on case-insensitive file systems.

Alias "/image" "/ftp/pub/image"

In your case, this would be like:

Alias "/karaoke" "/var/karaoke"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download