I have Synology DS1515+ and I've installed Web Station with Apache and PHP on it. I have web directory (full path /volume1/web) in which I can host webpages.
I have PHP file with tag video in which I would like to have video from video directory (full path /volume1/video).
So in web directory in PHP file I have something like below, but video file isn't hosted:
<video id="video" autoplay>
<source src="/volume1/video/movie.mp4" type='video/mp4'>
</video>
I also tried related path like '../video/movie.mp4' but it also doesn't work.
I read this question: Access synology shared folder from PHP and I edited open_basedir but it took no effect.
Thanks for help.
Your src needs to be relevant to the apache path being served.
E.g. if apache is serving content from /volume1/website/public_html your source is relative to this folder. You won't be able to break out of this to get to /volume1/video/movie.mp4 either.
Try looking at apache getting started here https://httpd.apache.org/docs/trunk/getting-started.html
Some will no doubt go on to voice their concerns - and normally I'd say rightly so.
However, goto Web Station, click on PHP Settings, select PHP version and add /volume1/video/ to the end of open_basedir, i.e. add :/volume1/video/ paths are split by a :
I do similar to serve photo's from outside the web root. I then have a PHP script to fetch the file required from /volume1/photo (in my case). and use like src="getfile.php?name=file.jpg" which can access the file you want and provide it. Bit of a workaround but it works.
Related
I have saved a PHP file to my Applications/XAMMP/htdocs directory and I want to run it in a browser.
I have used all sorts of url combinations including:
http://localhost/xammp/htdocs/HelloWord.php
http://localhost/xammp/HelloWord.php
amongst others and I cannot find the right url.
I am using XAMPP on a Mac Majove.
If you installed the XAMPP VM version, then you can probably access it via http://192.168.64.2/HelloWord.php (check the General tab in the XAMPP app for the IP address)
If you installed the native version, then I guess it is
http://localhost/HelloWord.php
The htdocs/ folder is the document root. Its content is served under the server address. Neither the xampp nor the htdocs folder will be part of the URL. The paths are relative to the document root, and you shouldn't be able to access parent directories above htdocs/ (although server-side code such as PHP has access to the file system and may work with files outside of the document root).
First of all, expecting the php file to have information that can be visualized in a web browser, inside xampp if you have the .php file in the htdocs folder you should be able to visualize it like this:
http://localhost/HelloWord.php
Found it by trial and error, quite different from what I took from various instructions on line:
http://localhost/HelloWord.php
XAMPP's default root should be "htdocs" or "www". Put your PHP files into those folder and try again.
if it is not work, find the configuration of Apache and PHP in XAMPP folder.
I just installed the latest MAMP on Mac, and found this hard to understand:
The document root seems to be "~/MAMP/htdocs", because "localhost" will open the index.php file under this folder.
However, "localhost/MAMP/?language=English" opens "~/MAMP/bin/mamp/index.php". I know that in URL strings between "/"s are not necessaries folders, but if they are not folders, how was it constructed and how does the system know where to find the right files?
I know this is a pretty basic question which I can probably get answers by myself, but I don't know what key word to search. Tried "php url construction" and "php url folder" but no luck. So a proper keyword suggestion is also appreciated.
It is setup by default by MAMP. If you open up MAMP/conf/apache/httpd.conf in a text editor and scroll down to around line 368/369 and specifically line 408 you will see that it is an Apache Alias. it is setup for easy navigation, instead of having to type http://localhost:8888/bin/mamp you can just type http://localhost:8888/MAMP. It is also setup as an Alias to ensure that you can still access the web tools if you change the document root from something other than /Applications/MAMP/htdocs.
Are you sure http://localhost:8888 has the docroot set to ~/MAMP/htdocs as you suggest? Reason I ask is that looking at your first image the text says the docroot is /Applications/MAMP/htdocs. Also the docs say it should be in the /Applications/MAMP/htdocs. I think the issue is that you do not have MAMP in the Applications folder where it needs to be.
https://www.mamp.info/en/documentation/
Where should I store my HTML and PHP pages?
By default, PHP and HTML Pages should be stored inside the MAMP
"htdocs" folder which is located in the MAMP Application directory
/Applications/MAMP. This folder is called "Document Root". You can
change the path for the Document Root in the MAMP application's
Preferences Panel:
Also please note this https://www.mamp.info/en/documentation/#q8
Will MAMP work if the MAMP folder is not located in the Applications
directory?
No. In order to work properly the MAMP folder has to be located in the
Applications folder.
I am trying to make Intranet application in CentOS/Linux which lets users browse and select file placed anywhere on server or networks paths.
I just need to select file so I can get its full path where it is placed.
User must be able to browse folders as one would by
file --> open --> browse ...
paths could be ..
/home/username/
/datadrive/ --> mapped drive etc.
My current choice is Encode Explorer enter link description here
But I want it to work outside /var/www/html folder. What are my options ?
In Encode Explorer index.php, edit line 350 according with your desired base dir.
Be aware that working outside of the www-folder may require you to remove the open_basedir restrictions introduced probably by your php.ini or an .htaccess.
Using a standard LAMP server with full control, I need to upload an image from DomianA using a PHP script to a directory on DomainB. The server has suPHP and mod_security in place.
Currently using an absolute path to DomainB I am getting the error:
Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect.
I tried to chown the upload directory on DomainB to the user of DomainA (where the script is being run). With no luck.
After researching I have found two potential solutions, and want to see if there are any better methods. And maybe some code to get me going in the right direction.
Symlink - so basically have a dir (below the domain level I guess?) then have each domain have a symbolic link to that location.
Modify my httpd.conf - not sure what to do, but I don't want to open any potential security holes by doing this.
If domain B only needs to serve up files from that directory and not modify them, then put the directory somewhere in domain A's tree, with proper permissions to allow the uploads.
You can then configure domain B to access that directory via an alias:
Alias /path/to/the/files/in/domain/A /dom_a_dir
Then you can access the files directly via
http://dom.b.com/dom_a_dir
I'm trying to navigate to C drive via PHP on my local drive, this one line of code works fine:
<a href='<?php echo'file:///C:\Users\Emily\Documents\'?>' TARGET="_blank" >Clcik Me</a>
This works fine from my local drive but as soon as this is on my sever it throws an error. I've been trying to strip and replace slashes but to no luck, hope sone one can help me.
This is because on the server there is no "C:\Users\Emily\Documents".
You need to make sure that the filepath you use is available to you on the server. My recommendation would be to setup your local machine to have the same filepath which exists on your server.
For example lets say you have a folder named Web, in which you keep the following files and folders:
index.php
\images (This is another folder)
From your file if you wanted to access a file in the images folder, from your index.php file you would access it as "images\FileYouWant.jpg"
Your server should have the same setup so you copy index.php and the images folder into the folder on your server, this way they keep the same file paths.
You can find more on file paths here
you can't access local file links from remote servers. if that were still possible (Like it was many years ago), a remote site could get at your local files...
Your server OS maybe not windows and file path is different!
Try to debug with <?php var_dump(real_path('file_path.php')); ?>