is there any way that a folder on my site
automatic zip and ready to download
mean for example a folder on my site in which are different files like different songs mp3 files
i want that i can also give people an option to download all movie songs in a folder
and show their link
when the click on link that folder automatic convert in zip and ready to download ?
i think my ideas is workable ?suggestion plzz how it will exactly work no
realcoder is online now Report Post Edit/Delete Message Reply With Quote Multi-Quote This Message Quick reply to this message
realcoder
View Public Profile
Send a private message to realcoder
Find More Posts by realcoder
Add realcoder to Your Contacts
Reply
sorry above post is little wrong my question is only this
is there any way that a folder on my site
automatic zip and ready to download
mean for example a folder on my site in which are different files like different songs mp3 files
i want that i can also give people an option to download all movie songs in a folder
and show their link
when the click on link that folder automatic convert in zip and ready to download ?
i think my ideas is workable ?suggestion plzz how it will exactly work no
This is what you need http://www.phpconcept.net/pclzip, they have great documentation and i haven’t had any issues with them
can u little describe how i zip a folder using their class
It has all the information you need in there documentation, if you have issues understanding it try as much as you can then we can you further.
infect m not familiar with OOP so it’s difficult to understand exact i have try it before but don’t get much
i think i got it
require_once(‘pclzip.lib.php’);
$archive = new PclZip(‘archive.zip’);
$v_list = $archive->add(‘foldername’,
PCLZIP_OPT_REMOVE_PATH, ‘dev’);
i thik here is some problem i can’t use varibales in values ?why?if yes how
The method “add” is for when your appending files to an existing zip file, the method you need to use is “create”. See if the code below works for you
// Set the directory
$dir = "A Flat";
$fileList = array();
if (is_dir($dir)){
if ($open = opendir($dir)){
while(false !== ($read = readdir($open))){
if ($read != '.' && $read != '..'){
echo $read." - File Size: ".filesize($dir."/".$read)." bytes<br />";
$fileList[] = $read;
}
}
} else {
echo "Unable to open the directory at \\"$dir\\"";
}
} else {
echo "The directory ( $dir ) is not a valid path!";
}
// Make sure the array is at least "1" value
if (sizeof($fileList) > 0){
// Include the PCLZip class
include_once('pclzip.lib.php');
// Create a new instance of the class
$archive = new PclZip('mp3_files.zip');
// Build a list of the files
$files = implode(', ', $fileList);
// Add the files to the archive
$v_list = $archive->create($files);
// Finish up
if ($v_list == 0){
die("Error : ".$archive->errorInfo(true));
} else {
header('Location: mp3_files.zip');
}
}
well brother can’t i pass it values through variables because i try to do give values through that don’t work
and which code u write that also giving wrong error
Error : PCLZIP_ERR_MISSING_FILE (-4) : File ‘01 - Meetha Sa Ishq.mp3’ does not exist
even file is exists
Thats my fault, in the while loop the appending values should be
$fileList[] = $dir."/".$read;
Now this one
Error : PCLZIP_ERR_MISSING_FILE (-4) : File ’ A Flat/02 - Dil Kashi.mp3’ does not exist
well got this problem there was one extra space in explode
well thanks
No problem, everything is working alright for you?
yes
Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive ‘bollywood/a/Anjaana Anjaani.zip’ in wb mode
gettings this error on linux centos
working good on windows when i was checking script
folder permissions are also 777