Download Full directory from PHP - php

a simple question that's freaking me out. I created an upload zone in which files are uploaded to a folder that was dynamically created by an mkdir. But if I wanted to download that folder how do I proceed? I don't necessarily need it to be made .zip just for me to be readable and that the files inside it are intact.
I tried pointing directly at the folder with the following href but it does not work.
<td align="center"><b>Scarica Bolle</b></b></td>

Related

File upload in codeigniter in shortcut folder

This is not the first time I am doing file upload using CI. However in this particular case I want to upload images or files to shortcut folder created at project root. This is what my project root looks like in following image:
So basically what I had been trying to do is using php filesystem function is_dir('goku') (goku is shortcut folder as shown in above image that links to C:\Users\Name\Desktop) and if true then create a sub-folder inside it and insert the image or file in that sub-folder. However I didn't find any way to make the shortcut folder recognize as directory and returns file upload error -The upload path does not appear to be valid. Upload works fine on other folder. I know that php is not recognizing the shortcut folder as directory because on running is_dir('goku') returns false. I have gone through all probable solutions but now again back to where I started. Any helpful hints regarding this is highly appreciated. Thank You!!!
Using the library Codeigniter
library upload single file and multi file
Easily upload .

displaying pdf files located in temp folder using IFrame

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" >

Can back up specific files automatically from FTP to a specific folder using PHP?

I have lots of backup files in my FTP.
The file name like : index.php.bk-2013-12-27
I want to back up those files to the folder named /backup/
so inside of my httpdocs folder looks like this.
index.php
backup/index.php.bk.2013-12-27
the following both methods are fine to done this.
01. if any file contain name .bk that should be backed up automatically to the folder backup
or
02.
create a text file named backup_move.text that file contains the
paths of files that need to be copied and placed it into the httpdocs folder.
then the php script extract those file path from the
backup_move.text and sync the files to the folder named backup
How can I do this with some php coding.?
Any help will be very much appreciated.
It can be done (Both solutions).
But you need to tell if the solution (01) need to be recursive or Not. I suppose you know php has got a "time" to run (standard are 60 seconds), so you know that the file you need to backup cannot require more then 55 seconds to get a backup.
You can try and use the next link, it will backup completly a site, db and file and put it into a zip file. It need to be configured a little, but it can help.
http://www.starkinfotech.com/php-script-to-take-a-backup-of-your-site-and-database/

PHP How to ZIP multiple files located in different paths?

I have 16631 files hosted in a webserver, 2719 of them are text files that contains a list of specific files located on the server.
Using PHP, is possible to create a ZIP for each text file?
could be the text file name as ZIP file name?
I want to keep the same directory structure in the ZIP file.
Thanks in advance.
Taking the suggestion from Jeff Hines, you could use the ZipArchive class to create the zip.
In Pseudo code
Get List of Text Files in your folder
Read Text file and get list of files to add to zip
Using ZipArchive add each listed file to your new zip file.
Write flag to specify you've done this file.
You might need to run it on 10 files at a time since it may time out.

PHP Download file from non-hosted directory

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');
?>

Categories