If I have a php file on my root folder on my website, is there a way to go to a download line with that file and download the file to the directory where the php is rather than to the computer>
As #Cale_b said, no, not without FTP. The PHP file will execute if you try and get it through the browser. Why do you want to do that anyway?
Related
I tried downloading a directory folder using wget, and it seems to have worked properly. However all the PHP files are empty. I know that they should not be empty as they show a file size on the web directory.
The folder I am trying to download is here:
https://www.isuperman.tw/wp-content/plugins/automatewoo-referrals/
I used these directions to download recursively with wget.
How to download HTTP directory with all files and sub-directories as they appear on the online files/folders list?
Any ideas on why they are downloading blank/empty?
view-source:https://www.isuperman.tw/wp-content/plugins/automatewoo-referrals/automatewoo-referrals.php
nope the files are empty, doesnt matter whats the content of the files.. if you use wget to download a file, wget simulates A browser and get the parsed php content from the server...
and these seems to be empty
if you want to download the files with php, use ftp or the server must not parse these files and deliver its raw content
I've got the following situation: I have some files with hashed filename on a cdn. Now I want a php script which redirects to the files (download) and give them another name. Is there a way without using readfile? The problem with readfile is that it doesn't make sense to download the file from cdn to my webserver and then download the file from the webserver to local computer.
I have a folder containing PHP files. When I open those file through localhost, I get the list of all the files inside that folder. Instead I want a specific PHP file to be opened when I click on that folder through localhost. How do I do that?
Put a file named index.php inside your folder and code inside that.
index.php
<?php
echo "I will be opened first";
Normally, when you start a folder in FTP mode, it will automatically make a PHP file named index.PHP. I would recommend using a different FTP program if this occurs again.
I've been able to upload a file through PHP to a non-hosted directory (directory is not on the website) with read/write permissions for the PHP file (www). How would I download the file from this directory? I've been able to list the contents of the directory, but clicking on the files (made the filenames links) does not work as the computer attempts to download the file from the path on the server. I'm new to PHP, so all help is appreciated. Thanks!
Edit: Before I get down votes for this being a broad question, I just want to know how to access the files in the non-hosted directory and pass them to the user. I already know how to download normal files hosted on the website. Thanks!
You can use a delegating PHP file for file access. I don't know anything about your structure, but if you can write it, you can (presumably) read it back with file_get_contents:
<?php
echo file_get_contents('/the/path/to/the/unhosted/directory/file.ext');
?>
Is there a way to add files to a zip file from another server with php's zip extension? ie.
addFile(array('localfile.txt,'http://www.domain.com/remotefile.txt'))
//(that obviously does not work)
I suppose I can download the files to a temporal folder and then add them to the zip file, but I was looking for a more automated solution or a function already made
use file_get_contents() and ZipArchive::addFromString()
$zipArchiveInstance->addFromString($filename, file_get_contents($mediaUrl));
This writes the contents fetched remotely straight into your php object (no need to write/read temp file)
It's not hard to read remote files in PHP.
file_get_contents("http://example.com/remote.txt");
Or to copy them locally:
copy("http://example.com/remote.txt", "/tmp/local.txt");
Whichever way you do it, the contents are going to have to be transferred to a local temp folder or memory before you can do anything with them.
Fetch them with cURL, add them from TEMP directory.