Some background. I am using XAMPP on my laptop as a standalone, single-user server. I have a PHP/Ajax/JavaScript application that to all intents and purpose is a contacts and contact management system.
At the moment, web links are linked to the records as they are displayed to provide relevant content which the user selects by clicking the hyperlink. I would like to have the ability to include file links as well. So to my question:-
I have a file URL of the kind file: ///G:/home/scans/passports/tony0001.pdf which works as expected when typed into the address line of Firefox and Chrome, i.e. it fires up Adobe Reader and opens the PDF file. I use PHP to generate the relevant anchor statement using the information retrieved from the application. I give the href below:
href=file://G:/home/scans/passports/tony0001.pdf
The link does display as a URL and if I hover the cursor over the link it shows the correct File URL. If I click on the URL nothing appears to happen. I don't see any error messages.
So, my question is, is there a PHP.INI option I need to set to allow this? The functionality I am looking for is to be able to embed any sort of URL into my application and have it fire up the right handler and file.
I understand the point made regarding a potential security issue, but as I explained, I can type the file URL into the browser page and it opens as expected.
Update 16/10/15
The solution to this is to embed a windows shortcut which points to the target document in the xampp/htdocs directory (or a sub-directory). The links then work correctly using the very simple form of href=tony0001.pdf
Browsers disallow local file access such as file:// because it would be a security risk.
Related
I have files stored in the server with the Plesk panel, currently, any person with the link of my site can access the file and download it.
Is there any way to prevent the download for all the users?
The general approach is to create a folder that is not in the root folder of the web site. In other words, you don't allow nor have valid URL's to a folder as a result. This does mean then you have to build some type of web page that can say list out some files and a button to click to download such files.
In other words, no valid url's exist. This tends to suggest that you have some type of grid or display of files. often even a database table to drive such a display is used.
When the user clicks on say a button on that grid row, then code behind can fetch the file, and "stream" it down to the user. The end result is thus no valid url's or resolvable path to the files exists.
Also, from IIS, turn off directory browsing. and thus again no valid URL's to the files exists.
The other approach? You can build a custom http handler. This approach is quite common. That way, any url that ends in .pdf will be trapped, and thus not allowed. As noted, this again means you have to provide a "list" of files, and a button to download - and again you can then stream the file from the server.
So there is quite a few ways, but ultimate, I as a general rule don't allow files to be downloaded or even accessed by URL's. I always provide some kind of web page, and a list of choices for the user. The code behind is what actually fetches the file, and then streams it down to the browser.
So, you can
Search for how to build a custom http handler for pdf files in asp.net
Search for how to stream a file to users in asp.net
how to turn off directory browsing in IIS.
There are a truckload of options here - in fact too many to really post and explain in Stack Overflow answer.
I have a code of online shop on Prestashop, and I have for example content="Shop on PrestaShop" in meta-data of current page, but when I'm trying to find that String in project in Webstorm to localize which page file it is, I get nothing.
So I guess it's some PHP magic working there. So now I have huge problem with finding proper file in order to change that String. Is it possible to check a filename and it's extension via Google developer tools? I'm starting site from server, not localhost.
You can only find the files that are delivered to client's machine in chrome developers tools by visiting:
Inspect > Sources
The server side files can be visible only if you can see them in URL. If the path is re-written using something like .htaccess in apache, then there's really nothing that you can do to find out the file.
These type of files are meant to be present only to hide the actual file path.
I have an ASP page, in which the user chooses a value (e.g drawingId) from a list box, and according to this value, ASP builds/calculates a file path, e.g. c:\drawings\file1.pdf, in order to show this pdf file to the user. This path refers to the client's computer, where these pdf files are stored. The server queries the database and knows only the association between the drawingId and the path at the client's computer.
How can I open this pdf file?
I've read similar questions, like How can my web application written in Java open a file on the client side? or Can javascript access a filesystem?, but I haven't understood how to proceed.
I would like this to work with all browsers and also implement this functionality in a PHP site.
Use file:///
e.g. file:///c:/filename.pdf
Well I guess after user selects option from a list box, you could construct the path and redirect user to that path which should open the pdf file
eg.
file:///C:/foldername/filename.pdf
it not possible to open client side file from server side code as it running at server side, also due to some security reason browser does not allow to browse client location
refer link Open local folder from link
Using CKeditor on my project.
Recently installed fmath plug-in. Followed all instruction and created PHP file that will get image from editor and save in website directory.
The problem is, there was something wrong with fmath editor: when I tried to press "Ok" (it must send generated image to php file and show result image in main CKeditor textarea) nothing happened. I activated webconsole of FF and as you see browser tries to get some crossdomain.xml. I think editor configuration has nothing to do with this problem. fmath editor doesn't even try to send something to php file (firebug doesn't show any XHR activity)
Can anyone explain me, what can I do in that case?
It is a security issue: crossdomain.xml contains the security policy for the domain you are trying to access. Resolving this issue is (relatively) easy: Just add a crossdomain.xml at the top level of your web server's content root.
You can learn all about security policies and the Flash security model in Adobe's documentation, or download this pdf.
I am placing href links to remote files for download simple as this with ajax:
Link
but it opens in new window and cuts off http:// and returns not found error, although if i refresh the page it will start downloading the file.
Maybe i could specify the content type and pass with header somehow but i dont want to pass the file through my server, it should download it from remote link.
Hope i could explain well.
Thank you.
sounds like the remote site has some protection against hot linking.
Are you certain that the link is correct? Try testing it externally first using an online flash player such as http://www.flvplayeronline.com/ . If the video plays then as #EvilSpaceHamster stated it could be a permissions issue on the server. I noticed you stated download? Is this a requirement or do you just want to grant the user access to view the file?