Is it possible to create .php file and when I access it, I can also access all my other ftp files? Download them, edit them or upload other files. It would be very comfortable.
We've used this in the past:
File Thingie • PHP File Manager
It's nice and simple and is just a single php file.
Something like PHP File Manager?
I had good results with File Thingie myself.
Related
I'm building a web app with MySQL/PHP/JS.
I have files in htdocs/mywebsite/foo/foo1/ path. Example:
htdocs/mywebsite/foo/foo1/image.png
I need to move these files to:
htdocs/mywebsite/foo3/image.png
Any help?
There is a rename() function in PHP that will just rename a file or will move it from one directory to another if the from and to directories are different.
<?php
rename("htdocs/mywebsite/foo/foo1/image.png",
"htdocs/mywebsite/foo3/image.png");
?>
In order to move files on a fileserver you need to use FTP (File Transfer Protocol). Programs like FileZilla could help you with that. A proper webhost should also have a FTP client on the control panel.
Using FileZilla:
Login to your webserver, simply cut and paste or drag and drop.
if you need to simple move all files from FTP using FTP tools like filezila or many other FTP software.
second from putty use mv command to move file.
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');
?>
I am trying to download some files. I have written a php script that can gather all of the address of the pdf files I need to download into a array but the file names on that server are odd. How does one go about downloading pdf files with php?
you can try (if I understand your question correctly)
file_put_contents('/your/file/name.pdf',
file_get_contents('http://www.example.com/oddFile.pdf'))
Check out the file or file_get_contents functions. It can take URLs as well as local filenames.
http://www.php.net/manual/en/function.file.php
http://www.php.net/manual/en/function.file-get-contents.php
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.
I have designed an online editor with which a user can create files and folders on the server. Suppose a user creates the below files and folders.
/docs/abc.txt
/docs/def.txt
/docs/work/assignment.txt
I want to write a PHP script to combine the files into a single ZIP file so that it makes it easier for the user to download them with one click.
The only purpose is that I should get a single file with the directory hierarchy maintained which the user can download and uncompress on his system to get the original files and directory structure back. I don't care even if the ZIP file is not compressed.
Note that I am using a shared server and do not have access to execute external commands.
ZipArchive class is what you need. Using this you can add directories and file to an archive.
This is a common requirement and has been solved. Try and check out this class: http://www.phpclasses.org/browse/package/2322.html
More tutorials at:
http://davidwalsh.name/create-zip-php <-- this has a similar example if you scroll down
http://www.w3schools.com/php/php_ref_zip.asp
Assuming you have permission to execute an external command, you could use exec to run an external command-line capable ZIP program such as 7-Zip.