bobcooper
-
Posts
10 -
Joined
-
Last visited
Posts posted by bobcooper
-
-
Hi there,
I'm trying to create a zip file from an array of images that are posted from a form using the following code:
<?php $shortlist = $_POST['shortlist']; $dir = $_POST['imageDir']; $imageDir = $dir; $imageArr = array(); $imageArr = preg_split('/\r\n|\r|\n/', $_POST['shortlist']); array_shift($imageArr); /* foreach ($imageArr as &$value) { $value = rtrim($value); $value = $imageDir . "/" . $value; } */ $imageTotal = count($imageArr); $zip = new ZipArchive(); // Load zip library $zip_name = time().".zip"; // Zip name if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE) { // Opening zip file to load files echo "* Sorry ZIP creation failed at this time"; } else { echo"zip created"; chmod($zip_name, 0755); foreach($imageArr as $file) { $hostedFile = $imageDir . '/' . $file; echo '<img src="' . $hostedFile . '" />'; $zip->addFile($hostedFile,$file); } $close = $zip->close(); if ($close) { echo 'File Closed'; } else { echo 'fail!!'; } echo 'Download these images as a <a href="'.$zip_name.'">ZIP file</a>.\n'; } ?>
The php file is in a separate folder e.g. www.website.com/php/zip-test.php to the images folder as I want to be able to re-use it for other folders.
I get as far as adding the files to the zip but when I try to close the zip it fails. The only thing I can think is that the $hostedFile is a relative link, e.g. /images/image1.jpg rather than http://www.website.com/images/image1.jpg so it's not finding the image to add to the zip
So I tried adding the full website path to the image but it still does not work. The image is displaying fine when I echo it as an image, it just doesn't add to the zip.
Any ideas?
Thanks,
Bob
-
Hi there,
I design a lot of Photography websites using flash and am looking for a simple CMS solution to update images and edit text pages. Most of the CMS's out there seem overly complicated and full of many features that I just don't need, does anyone know of any php based CMS that would meet the following requirements:
1. Need to be able to edit txt files.
2. Need to be able to upload multiple image files at once.
3. Image needs to be re-sized on upload to a specific either height or width (depending on the site).
4. Need to be able to create a thumbnail from the image by grabbing a selection / cropping new image (again to a specific size depending on the site).
5. Need to be able to change the image order of the images online without re-uploading everything, so they would be re-named as 1.jpg, 2.jpg, 3.jpg etc
6. I would need to be able to update the CMS depending on each site, so some sites might need thumbnails, some would not, some might need more/less text pages etc.
Any thoughts or suggestions would be really appreciated.
Thanks
Bob
www.bobcooper.org.uk
-
Ahhh, I figured it out, wordpress is set to save all revisions to a post as well which messes up the order, and adds duplicates.
Thanks for your help.
Bob
www.bobcooper.org.uk
-
Hi thanks for that, I have managed to get the table structure from the following address:
http://codex.wordpress.org/Database_Description
So I am now importing post_title and post_content from wp_posts and yes the blog details are there, the only problem is that the order is very strange and the posts are duplicated, I am assuming this is for different categories, but I can't figure out how to sort it out!
Cheers,
Bob
www.bobcooper.org.uk
-
hi there,
I am trying to access information from the wordpress mysql database that I have set up on my domain. I am using amfphp to access the info, but I can't seem to find any information on the table structure of the wordpress database.
Does anyone know any information on this or where I can find out more?
Thanks,
Bob
www.bobcooper.org.uk
-
Hi there,
I am having a problem copying a folder and its sub folders. When I try the script on my computer it works fine, but when I upload it to my website it only creates a new folder, it does not copy the files. I was thinking it might be something to do with permissions so added chmod settings but that does not work either.
Here is the code:
<?php $dir = "../"; $count = 0; if(is_dir($dir)) { if($handle = opendir($dir)) { while(($file = readdir($handle)) !== false) { if($file != '.' && $file != '..' && $file != 'upload'){ $count++; } } closedir($handle); } } $issueNo = $count + 1; $destination = $_SERVER['DOCUMENT_ROOT']."/newsletter/issue_".$issueNo; $source = $_SERVER['DOCUMENT_ROOT']."/newsletter/issue_1"; function full_copy( $source, $target ) { if ( is_dir( $source ) ) { @mkdir( $target ); chmod($target, 0777); $d = dir( $source ); while ( FALSE !== ( $entry = $d->read() ) ) { if ( $entry == '.' || $entry == '..' ) { continue; } $Entry = $source . '/' . $entry; if ( is_dir( $Entry ) ) { full_copy( $Entry, $target . '/' . $entry ); continue; } copy( $Entry, $target . '/' . $entry ); } $d->close(); }else { copy( $source, $target ); } } full_copy($source, $destination); ?>
Your help would be greatly appreciated,
Thanks,
Bob
www.bobcooper.org.uk
-
Doh! I just realised what's going on, the other site I was using it on does not let me use php! I tried it on another site and it worked fine!
Thanks for your help though.
I think i need some more sleep!
Bob
www.bobcooper.org.uk
-
OK I have changed that, but it is still not importing the code into the file, it imports it fine from my own site but not from an external site.
Bob
www.bobcooper.org.uk
-
Hi there,
I have a php file on my website that holds all the navigation elements for my website which are imported using php include, so if I want to change the structure of the site I do not have to edit every page.
I want to place an upload page onto my clients website (separate to my own) that uses the same php navigation file. I have tried using php include from the clients website to the php file on my website but it does not seem to import it.
this is the code i am using:
<?php include("http://www.bobcooper.org.uk/navi/naviBg.php"); ?>
anyone got any thoughts on this?
Thanks,
Bob
www.bobcooper.org.uk
zipArchive problems...
in PHP Coding Help
Posted
Hi,
Thanks for your reply, I've tried adding $_SERVER["DOCUMENT_ROOT"] to the $imageDir but it still does not work and it also does not echo the images either.
Bob