I have a Laravel App that can upload file to a folder.
The folder is a symlink to /media/folder_name, that is a mount point of a Windows share (mounted via fstab).
Upload and Download works.
The download action returns a copy of the file:
return response()->file($path_file);
I want that the download action to show me the original file (saved in windows folder, like: //192.168.1.2/share/folder/file.pdf).
It is possible?
After some research, direct link to local resource is denied in Firefox and Chrome for security reasons.
So, the solution is to install the Local Filesystem Links extension for firefox. In Laravel, return a blank page with the link to the resource, like: file:////192.168.1.2/folder/file.pdf.
Finally, when you click the pdf link, the original resource is opened with the default program (Adobe Reader, for example).
Related
Some log files are saved in cloud server and it is placed in another load balancer portal to download it. If I browse the load balancer URL we can see the files to be downloaded. When I click this file its get being downloaded. How this file can be downloaded from Linux commands / php scripts
In Linux terminal using wget command to download file from specific url.
And using php script to download file, you can use file_get_content() and file_put_content() to download file.
I hope this answer helpful to you.
I've set up youtube-dl on my shared Debian 3 host so I can access it via an URL to pass address to what I want to download so it would download it on my host.
I was wondering if there is a way to display URL links to file(s) downloaded by last request on a web page for easier download.
So for example, if you call domain.com/youtubedl.php?url=www.youtube.com/watch?v=000000 would download it and then display this on the page:
http://domain/download_directory/youtubefile.mp4
so you can easily download it by clicking on that link.
Thanks
By default, the video will be saved in the current operating directory of the script which has called youtube-dl. The default filename is videoname-videoid.extension. For example, I downloaded this video with the name "PHP Programming" and the video ID of "7TF00hJI78Y". When it was downloaded, it was in the directory of my batch file which I used to call youtube-dl, and was called "PHP Programming-7TF00hJI78Y.mkv". The extension can be defined as per the following information from youtube-dl's Git-Hub page. I would suggest not leaving the files in this directory, however, keeping youtube-dl outside of the public website directory, and moving the video files through your script to a public directory for downloads.
Well, I got an API which read binary file from database and store it as "PDF" in windows temp folder, then it sends the path to that file to "PHP" page. What I want is to display that file over the browser.
The API returns the PDF file path: C:\Users\username\APPDATA\Local\Temp\some file.pdf. What I have done is setting that path to an iframe in my page,
but it shows nothing.
What am I missing here?
You should convert that local path to an url one.
Http://www.yourpage.com/folder_where_you_keep_those_files/file.pdf
And give the proper folder and file permissions.
The PDF is on YOUR computer, the user cannot access YOUR C:\ drive.
You cannot exchange your client-side files with someone server-side.
Store your PDF file on the server somewhere and set that path in the iframe.
You need to move that file from you local path (it can be your tmp folder or another folder that is not in your web accessible path) to your web directory so that you can put that in your iframe source.
Eg:
<iframe src="http://yourwebsite.com/somepdf.pdf" width="1000px" height="800px" >
I can't seem to find out whether it is possible to create a download link via Response::download() method with an external URL file source instead of local file path. For example:
Response::download('https://s3.amazonaws.com/bucket/file.zip','Download.zip');
I'm hosting my static and upload file on Amazon S3 and would like to create a download link when the requested users have access to it. All I get from the testing above is a FileNotFoundException error popping up stating that file does not exist.
As #James Binford said in the comments, it is not possible to use Response::download() for files on an external source. It may not be perfect, but you can always redirect to the URL
Redirect::away('https://s3.amazonaws.com/bucket/file.zip');
Depending on the file type it will open as "normal" download (e.g. zip files) or, if the browser supports it, the contents of the file will be displayed (e.g. images or text files)
Alternatively you can download the file from the server to the application server (e.g. using curl) and then use Response::download()
I am facing some typical problem from one of my project.
A section in my project need a file up loader. The requirement is when an user clicks on the browse button, it will not only opens up the local directory, the already uploaded file directory need to accessed as well.
In simple file uploader only the local directory can be accessed, I cannot able to fine any way out.
If any one can help me in this issue, it will be great for me.
Thanks in advance.
Is impossible to use to use the "file open dialog" / file uploader to browse files from server.
You can create a dialog inside your browser with (html,css,php).
Is difficult to give an example, because I do not know your requirements.
However you have to use two buttons, it will be easier:
upload from your computer
upload from the server
On click "upload from the server" , opens a window IN BROWSER (HTML+CSS) , that lists your folders and files on the server.
To implement this , read here:
http://php.net/manual/en/function.scandir.php
http://php.net/manual/en/function.readdir.php