i want to grab file from url using (file_put_contents) function but i can't and i got error (file not found) but i am sure 100% the path of the file is correct because when i clicked on the link for download the file in the same site it works but when i want to grab it it says not found.
see this path
http://bramegm.com/software/files/soft53/ElaSalaty.exe
when you try to grab it or also try to use (linux command like wget) you got that the file is not found but see the file page
http://www.bramegm.com/software/download/elasalaty/%D8%AA%D8%AD%D9%85%D9%8A%D9%84-%D8%A7%D9%84%D9%89-%D8%B5%D9%84%D8%A7%D8%AA%D9%8A
go to the bottom and you will see the same file path click on it and it will downloaded.
any help to grab this file without entering the site.
regards
You are trying to download the file from http://bramegm.com/software/files/soft53/ElaSalaty.exe but in the given URL i see the actual link is http://www.bramegm.com/software/files/soft54/ElaSalaty.exe. Please notice the difference in soft53 and soft54.
Related
I want to restrict a pdf file on my server from being viewed or downloaded. for example, when somebody types below url in browser and press enter.
http://example.com/pdf/sample-pdf1.pdf
the file should not be viewed or downloaded. instead, it should get redirected somewhere else or should display some error message
But, when i download the same file using php or html code, it should get downloaded
for example when i use below code in a php file, it should get downloaded.
[a href="http://example.com/pdf/sample-pdf1.pdf" download]Download[/a]
Insert .htaccess file inside pdf directory with content:
"Deny from all" -
That will not allow access that directory and files inside it via URL.
So essentially I want to insert the Path into my Database, as a string, I am not interested in uploading it - I just want local users to browse to the file then submit the form and the path to the file is added as a string. So when I echo this out into a url, people on the network can click the link to download it from the network location.
$location = fopen($_FILES["location"]["tmp_name"], 'r');
I've tried the above but I guess the file needs to be uploaded for it to get the path.
Any ideas?
Unfortunately PHP will not help you with this as it requires you to actually upload the file.
Likewise, as was mentioned in the comment you are not able to get the local file path either from the form. This is a browser standard and is done for security purposes. You can read more about it here: https://stackoverflow.com/a/4176605/8518859
The only solution in your case is to provide a text input and ask the user to paste the network path to the file. Perhaps if you provide them simple instructions on how to get the network path it will make their task easier.
I created a page for users to download certain files. I used the HTML download link to do this as so:
<a download href="/home/Uploads/someDir/someFile.PNG" >View</a>
This worked fine when I was developing on my laptop with WAMP. When I uploaded the code to our Centos 7 Server it did not work. I changed the Uploads, someDir, and someFile.PNG permissions to 777. I also made sure that the file path was correct. But the when the download link is pressed the file icon at the bottom of the screen says "Failed no file".
Maybe I need to do more with the permissions. I know that the folder that the html file is in has restricted permissions, but I would prefer to keep them that way. I do not know how that could cause an issue.
I am looking for debugging tips/possible causes. At this point I am clueless where to look.
The issue with the download not working is simply due to the fact that the path to your file is wrong. My advice on your root directory which is in most cases is var/www/html, create a folder called say somefoldername and manually upload the file to that folder then change the download link to be
View.
"Failed no file" has nothing to do with permissions. The path to your download file has most likely changed when the files were uploaded to the server. You should manually check to see if the file at
/home/Uploads/someDir/someFile.PNG
actually exists. If not you can change the link accordingly or move the download file to the appropriate location.
Another good alternative to solve this error is to put a dot '.' at the beginning of the url:
<a download href="./someDir/someFile.PNG" >View</a>
This way you will not need to indicate the complete url.
And if in the future the url changes, you won't have to modify the url.
In my case it works perfect, I hope it helps you too.
Just check the directory in which you are trying to fetch the file. Your looking file may be not present in that directory. Otherwise, you are using the correct piece of code.
<a download href="~/home/Uploads/someDir/someFile.PNG" >View</a>
This used to work and now it doesn't on my server. This is kind of a last ditch effort to try to figure out what is going wrong here. I'm simply trying to copy a profile image from Facebook to a folder on my server. Here's the only code I'm using:
file_put_contents("..//images/artist_pictures/artist_216.jpg", file_get_contents("http://graph.facebook.com/553451657/picture?type=large"));
After that runs I get a 0kb image file called artist_216.jpg. Any ideas?
I'm not too good with PHP, but I know that the picture URL you're using is a redirect to another file on Facebook's CDN. I'm guessing you need to somehow resolve the actual location and pull the contents of the redirect.
You need to adjust your php.ini file.
Change allow_url_fopen = Off to allow_url_fopen = on.
So I am running xampp and wordpress. I have an image uploaded to the uploads directory named "avatar.jpeg". It displays just fine. But when I delete it and upload a new image file named "avatar.jpeg", the server doesn't reflect the change and just shows the old file. But when I open the file in Eclipse or my explorer, then the server starts showing the change and displays the new image.
This is probably something basic which I never learned about. I tried chmod to set the file permissions on the new file but that didn't help.
The file will be cached in your browser. To force a reload, append an arbitrary variable to your file, e.g. <img src="yourfile.jpg?1234567" />
I also guess it's a caching issue like freddy K. does.
I would suggest to configure ETags on your Server.
Simply appending something to the URL may only help you when the appended string is changing on every update of the requested file(using the current timestamp or similar all the time will force the client to download the file on every request and slow down the page).
http://httpd.apache.org/docs/2.0/mod/core.html#fileetag