PHP - Gallery Only Copy Image Into Thumbs Folder When Chose Upload To Main Folders
Hi the file file upload whenever i upload an image to main directory it saves one image into photos folder and copy another into thumbs folder but whenever i upload image to a different album (not main directory) it doesnt copy the other image to thumbs folder what i'm i doing wrong
this is the line that i chose the folder... function make_locations ($locs) { $html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>'; foreach ($locs AS $key => $value) { $html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>'; } $html .= '</select>'; return $html; } this is the whole code <?php /** * create a sub album directory for photos * to be stored in */ function create_album ($album_name, $sub_album = 0) { global $db; $sql = "INSERT INTO " .ALBUMS_TABLE. " ( album_name, sub_album ) VALUES ( '" .addslashes($album_name). "', " .intval($sub_album). " )"; if ($db->query($sql)) { return TRUE; } else { return FALSE; } } /** * get a list of sub albums */ function get_albums ($sub_album = 0) { global $db; $sql = "SELECT * FROM " .ALBUMS_TABLE. " WHERE sub_album = " .intval($sub_album); $db->query($sql); // initialise album storage $albums = array(); while ($row = $db->fetch()) { $albums[] = $row; } return $albums; } /** * get a list of photos within an album */ function get_photos ($album = 0) { global $db; $sql = "SELECT * FROM " .PHOTOS_TABLE. " WHERE album_id = " .intval($album). " ORDER BY photo_id ASC"; $db->query($sql); // initialise album storage $photos = array(); while ($row = $db->fetch()) { $photos[] = $row; } return $photos; } /** * get a large version of a particular photo */ function get_large ($photo, $album = 0, $next = '') { global $db, $template, $account_details; // shall we get the next / previous photo switch ($next) { case "next" : $next_sql = "AND photo_id > " .intval($photo). " ORDER BY photo_id ASC"; break; case "previous" : $next_sql = "AND photo_id < " .intval($photo). " ORDER BY photo_id DESC"; break; default : $next_sql = "AND photo_id = " .intval($photo); break; } $sql = "SELECT * FROM " .PHOTOS_TABLE. " WHERE album_id = " .intval($album). " " .$next_sql. " LIMIT 1"; $db->query($sql); if ($db->num_rows() == 0) { return ''; } else { $photo_info = $db->fetch(); // note the total directory $location = 'photos/' .$photo_info['photo_proper']; // now we need to resize list($width, $height) = getimagesize($location); if ($width < 300) { $new_width = $width; $new_height = $height; } elseif ($width > $height) { $new_width = 300; $new_height = $height * ($new_width / $width); } elseif ($width < $height) { $new_width = $width * ($new_height / $height); $new_height = 300; } // work out the next link $next = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=next">Next</a>'; $previous = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=previous">Previous</a>'; return '<div id="largephoto"><img src="' .$location. '" height="' .$new_height. '" width="' .$new_width. '" class="large"><br /><div id="prevnext">' .$previous. ' :: ' .$next. '</div></div>'; } } /** * get an array of locations */ function get_locations () { global $db; // initialise array $locations = array(); // select albums $sql = "SELECT album_id, album_name FROM " .ALBUMS_TABLE; $db->query($sql); while ($row = $db->fetch()) { $locations[] = $row; } return $locations; } /** * make the locations table */ function make_locations ($locs) { $html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>'; foreach ($locs AS $key => $value) { $html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>'; } $html .= '</select>'; return $html; } /** * delete an album from the database * does not delete the photos in it */ function delete_albums ($album_ids) { global $db; if (sizeof($album_ids) > 0) { $sql = "DELETE FROM " .ALBUMS_TABLE. " WHERE album_id IN (" .implode(',', $album_ids). ")"; if ($db->query($sql)) { return TRUE; } } return FALSE; } /** * delete a set of photos */ function delete_photos ($photo_ids) { global $db; if (sizeof($photo_ids) > 0) { // select photo names for deletion $sql = "SELECT photo_proper FROM " .PHOTOS_TABLE. " WHERE photo_id IN (" .implode(',', $photo_ids). ")"; $db->query($sql); $unlink_ids = array(); while ($row = $db->fetch()) { $unlink_ids[] = $row['photo_proper']; } // now delete the photos if (sizeof($unlink_ids) > 0) { $sql = "DELETE FROM " .PHOTOS_TABLE. " WHERE photo_id IN (" .implode(',', $photo_ids). ")"; if ($db->query($sql)) { // remove photo from directory for ($i = 0; $i < sizeof($unlink_ids); $i++) { unlink("photos/" .$unlink_ids[$i]); unlink("photos/thumbs/" .$unlink_ids[$i]); } return TRUE; } } } return FALSE; } /** * upload a set of files */ function upload_files ($save_dir = '', $album = 0) { global $db; // check the save dir is writable if (!is_writable($save_dir)) { return FALSE; } // specify allowed file types $allowed_types = array ( 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif' ); // keep a list of uploaded files $uploaded = array(); // store bytes uploaded $total_bytes = 0; // go through the list of files while (list($key, $value) = each($_FILES['userfile']['name'])) { // check file has been passed if (!empty($value)) { // find extension $extension = substr($_FILES['userfile']['name'][$key], strpos($_FILES['userfile']['name'][$key],".") + 1); // time + $key for name $name = time(). "_" .$key. "." .$extension; // save url $add = $save_dir. "/" .$name; if (move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $add)) { chmod($add, 0777); // add photo to database create_photo($_FILES['userfile']['name'][$key], $name, $album); } } } return TRUE; } /** * insert photo details into the database */ function create_photo ($photo_name, $key_name, $album = 0) { global $db; // get the filesize if (!$size = filesize("photos/" .$key_name)) { $size = 0; } // insert the photo in the database $sql = "INSERT INTO " .PHOTOS_TABLE. " ( photo_name, photo_date, photo_proper, photo_size, album_id ) VALUES ( '" .addslashes($photo_name). "', " .time(). ", '" .addslashes($key_name). "', " .intval($size). ", " .$album. " )"; if ($db->query($sql)) { return TRUE; } else { return FALSE; } } /** * get a complete raw copy of the directory */ function get_dir_contents ($dir) { // declare content array $contents = array(); // check gallery exists if (is_dir($dir)) { if ($handle = opendir($dir)) { while (FALSE !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && $file != 'thumbs') { if (file_exists($dir. '/thumbs/' .$file) || thumbnail($file, $dir. '/' .$file, $dir. '/thumbs')) { $contents[] = $dir. '/thumbs/' .$file; } else { $contents[] = 'no_image.gif'; } } } } } return $contents; } /** * create a thumbnail of a photo and store it * in the thumbs directory */ function thumbnail ($filename, $source_file, $destination, $new_h = 75, $new_w = 75) { if (!is_file($source_file)) { return FALSE; } // get the image details list($old_w, $old_h, $type) = getimagesize($source_file); // create source image switch($type) { case 1: $source = @imagecreatefromgif($source_file); break; case 2: $source = @imagecreatefromjpeg($source_file); break; case 3: $source = @imagecreatefrompng($source_file); break; default : return FALSE; } // work out dimensions if ($old_w < $old_h) { $thumb_w = $new_w; $thumb_h = $old_h * ($new_h / $old_w); } elseif ($old_w > $old_h) { $thumb_w = $old_w * ($new_w / $old_h); $thumb_h = $new_h; } elseif ($old_w == $old_h) { $thumb_w = $new_w; $thumb_h = $new_h; } $thumb = @imagecreatetruecolor($thumb_w, $thumb_h); // create image imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_w, $old_h); // check we have a proper destination if (!is_dir($destination)) { mkdir($destination, 0777); } // save image switch ($type) { case 1: case 2: imagejpeg($thumb, $destination. '/' .$filename); break; case 3: imagepng($thumb, $destination. '/' .$filename); break; } // memory saving imagedestroy($thumb); imagedestroy($source); // thumbnail created successfully return TRUE; } /** * make the table to show the directories and photos */ function make_table ($list, $type, $row = 3) { // initialize gallery html array $gallery_html = array(); // check if we have a list > 0 if ($size = sizeof($list)) { switch ($type) { case "GALLERIES" : $gallery_html[] = '<div id="galleries">'; break; case "PHOTOS" : case "RAW" : $gallery_html[] = '<div id="photos">'; break; } // loop through list for ($i = 0; $i < sizeof($list); $i++) { // shall we open a new list if ($i % $row == 0) { $gallery_html[] = '<ul>'; } // add to list switch ($type) { case "GALLERIES" : // create the delete link $delete_link = ''; if ($_SESSION['logged_in']) { $delete_link = '[ <a href="admin.php?mode=deletealbum&a=' .$list[$i]['album_id']. '">Delete</a> ]'; } $gallery_html[] = '<a href=portfolio.php?albums='.$list[$i]['album_id'].'><img src="folder.gif" class="directory"><br />' .addslashes($list[$i]['album_name']). '</a><br />' .$delete_link. '</li>'; break; case "PHOTOS" : // construct photo name $name = $list[$i]['photo_proper']; // construct location $location = "photos/"; // create thumbnail if (!file_exists($location. "/thumbs/" .$name)) { thumbnail($name, $location. "/" .$name, $location. "/thumbs/"); } // construct date $date = '<div class="date">' .date("d/m G:ia", $list[$i]['photo_date']). '</div>'; // create the delete link $delete_link = ''; if ($_SESSION['logged_in']) { $delete_link = '[ <a href="admin.php?mode=deletephoto&p=' .$list[$i]['photo_id']. '">Delete</a> ]'; } // image information list($width, $height) = getimagesize($location . $list[$i]['photo_proper']); // add to the html $gallery_html[] = '<li><a href="' .$location . $list[$i]['photo_proper']. '" rel="lightbox[racing]" title="Photos"><img src="' .$location. "/thumbs/" .$name. '" class="picture"><br />View</a><br />' .$delete_link. '</li>'; break; case "RAW" : $gallery_html[] = '<li><img src="' .$list[$i]. '" class="picture"></li>'; break; } // shall we close the list if ( ($i + 1) % $row === 0 || ($i + 1) == $size) { $gallery_html[] = '</ul>'; } } $gallery_html[] = '</div>'; } return implode('', $gallery_html); } ?> Similar TutorialsHi guys, I am wirting a script to upload an image file, but I get the error: copy() [function.copy]: Filename cannot be empty in Obviouly it has something to do with the copy() function - (copy($HTTP_POST_FILES['product_img']['tmp_name'], $path)) I think it is not copying from my temp folder or something. Can anyone help me out? Code is: Code: [Select] //IMAGE FILE $file_name = $_FILES['product_img']['name']; echo '<p>File Name:' . $file_name . '</p>'; //IMAGE UPLOAD // random 4 digit to add to file name $random_digit=rand(0000,9999); //combine random digit to file name to create new file name //use dot (.) to combile these two variables $new_image_name = $random_digit.$file_name; echo $new_image_name; //SET DESINATION FOLDER $path= "uploads/".$new_image_name; echo '<p>Path:' . $path . '</p>'; if($product_img !=none) { if(copy($HTTP_POST_FILES['product_img']['tmp_name'], $path)) { echo "Successful<BR/>"; echo "File Name :".$new_file_name."<BR/>"; echo "File Size :".$HTTP_POST_FILES['product_img']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['product_img']['type']."<BR/>"; } else { echo "Image upload Error<BR/>"; } } Any help would be greatly appreciated! Thanks Hi guys, Im trying to resize and create thiumbnails while uploading an image but it doesnt work, as i am new to php and i have followed other tutorials, i might have made a mistake which i dont understand. i have a table called test (find attached image) and what i need is when i upload an image, it copies the location of both image and on fly created thumb into my database i appreciate your help & please excuse me for messed up code <?php session_start(); include ("../global.php"); //welcome messaage echo "Welcome, " .$_SESSION['username']."!<p>"; $username=$_SESSION['username']; //get user id & credit limit $query=mysql_query("SELECT id FROM users"); while($row = mysql_fetch_array($query)) { $id = $row['id']; echo $id; } $credit=mysql_query("SELECT credit FROM users"); while($row = mysql_fetch_array($credit)) { $creditcheck = $row['credit']; echo "your credit is: $creditcheck"; } $reference = rand(11111111,99999999); //image1 define ("MAX_SIZE","100"); define ("WIDTH","150"); define ("HEIGHT","100"); function make_thumb($img_nameone,$filenameone,$new_w,$new_h) { $ext=getExtension($img_nameone); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $src_imgone=imagecreatefromjpeg($img_nameone); if(!strcmp("png",$ext)) $src_imgone=imagecreatefrompng($img_nameone); $old_x=imageSX($src_imgone); $old_y=imageSY($src_imgone); $ratio1=$old_x/$new_w; $ratio2=$old_y/$new_h; if($ratio1>$ratio2) { $thumb_w=$new_w; $thumb_h=$old_y/$ratio1; } else { $thumb_h=$new_h; $thumb_w=$old_x/$ratio2; } $dst_imgone=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_imgone,$src_imgone,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if(!strcmp("png",$ext)) imagepng($dst_imgone,$filenameone); else imagejpeg($dst_imgone,$filenameone); imagedestroy($dst_imgone); imagedestroy($src_imgone); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if ($creditcheck<=0) Header("Location: buy-credit.php"); else if ($creditcheck>=0){ if(isset($_POST['register'])) $submit = mysql_query("INSERT INTO test (reference) VALUES ('$reference')"); { $image=$_FILES['myfileone']['nameone']; if ($image) { $filename = stripslashes($_FILES['myfileone']['nameone']); $extension = getExtension($filenameone); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=getimagesize($_FILES['myfileone']['tmp_name']); $sizekb=filesize($_FILES['myfileone']['tmp_name']); if ($sizekb > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $image_nameone=time().'.'.$extension; $newname="rentimages/".$image_nameone; $copied = copy($_FILES['myfileone']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } else { $thumb_name='rentimages/thumbs/thumb_'.$image_name; $thumb=make_thumb($newname,$thumb_name,WIDTH,HEIGHT); }} }} if(isset($_POST['register']) && !$errors) { $locationone="rentimages/$nameone"; $image1 = mysql_query ("UPDATE test SET image1='$newname', thumb='$thumb_name' WHERE reference='$referenceran'"); } } } ?> <html> <body> <form action='imagetests.php' method='POST' enctype='multipart/form-data'> File: <input type='file' name='myfileone'><p /> <input type='submit' name='register' value='Update'> <p /> </body> </html> Hi folks... Trying to get a bit of gallery code to work the way I want it to and would appreciate some feedback from more experienced folks... What it's doing, or is supposed to be doing, is taking a thumb called 'thumb.jpg' from each folder within my gallery folder and displaying it in reverse order on a page. I only want a maximum number of images to display on the page at any one time, so that if I end up uploading loads of folders in the future, it will only display a set amount of thumbs on one page. I want the thumbs displayed in reverse order, so that the newest appears first. Here's the code... and as far as I can see, it should work... and I'm sure I have had it working in the past (I've just come back to working on it after a while) however now, it's putting the thumbs in a random order. My folders are all in the gallery folder, and are named 001, 002, 003, 004, 005, 006, etc. I want them to display with 006 at the top and to de-increment, but only for the most recent 16 folders. Code: [Select] <?php $images = "gallery/"; # Location of galleries $cols = 4; # Number of columns to display $max = 16; # Maximum number of galleries to show if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo "<div id=\"updates\"><table><tr>"; $c = count($files) - 1; //$c = the number of files in the array, minus 1 = highest index in the array. for($i = $c; $i > ($c - $max); $i--) //$i = $c, $i is greater than the array count minus $max, $i de-increments on each loop. This will give us a countdown for the number of galleries required. { if($colCtr %$cols == 0) echo "</tr><tr>"; echo "<td><img src=\"" . $images . $files[$i] . "/thumb.jpg\" width=\"240px\" height=\"180px\" alt=\"" . $alt . "\" /></td>"; //echo'ing out the $file[$i] on the loop, will give us the last required number of files in the file array. $colCtr++; } echo "</table></div>" . "\r\n"; ?> I also want to work out how to set a start number for the galleries, so that I can paginate them... so, once I have 36 galleries (for example) I can have the latest 16 on the first page, and the next 16 on the 2nd page... and the 4 that run over would drift off into obscurity until I get round to deleting them... maybe with a variable named $min... How would I do that...? Like this, or differently? : Code: [Select] <?php $images = "gallery/"; # Location of galleries $cols = 4; # Number of columns to display $min = 16; # Minimum number of galleries to show $max = 32; # Maximum number of galleries to show if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo "<div id=\"updates\"><table><tr>"; $c = count($files) - 1; //$c = the number of files in the array, minus 1 = highest index in the array. for($i = $c; ($i + $min) > ($c - $max); $i--) //$i = $c, $i plus $min is greater than the array count minus $max, $i de-increments on each loop. This will give us a countdown for the number of galleries required. { if($colCtr %$cols == 0) echo "</tr><tr>"; echo "<td><img src=\"" . $images . $files[$i] . "/thumb.jpg\" width=\"240px\" height=\"180px\" alt=\"" . $alt . "\" /></td>"; //echo'ing out the $file[$i] on the loop, will give us the last required number of files in the file array. $colCtr++; } echo "</table></div>" . "\r\n"; ?> Any help greatly appreciated! hi all i need a script that will allow me upload images to 2 dif folders on my server and then add the info to my database along with some other form data. iv been looking all over for code or scripts for days now and have been playing with cut and copyed code but no look again any help i will be greatful for as im a noob to php but al learning quick here is my html form Code: [Select] <html> <body> <form action="add.php" method="post"> Project Name: <input type="text" name="pro_name" /><br> Thumbnail: <input type="file" name="thumbnail" /><br> ////// this image to ../thum Short Details: <input type="text" name="short_details" /><br> Full Details: <input type="text" name="full_details" /><br> Category: <input type="text" name="cat" /><br> Image1: <input type="file" name="image1" /><br>//// and image1,2,3,4 to ../images Image2: <input type="file" name="image2" /><br> Image3: <input type="file" name="image3" /><br> Image4: <input type="file" name="image4" /><br> <input type="submit" /> </form></body></html> here is my code for add.php witch only adds the info to the DB Code: [Select] <?php error_reporting(E_ALL); include ("../includes/db_config.php"); $con = mysql_connect($db_hostname,$db_username,$db_password); @mysql_select_db($db_database) or die( "Unable to select database"); $sql="INSERT INTO $db_table (pro_name, thumbnail, short_details, full_details, cat, image1, image2, image3, image4) VALUES ('$_POST[pro_name]','$_POST[thumbnail]','$_POST[short_details]','$_POST[full_details]','$_POST[cat]','$_POST[image1]','$_POST[image2]','$_POST[image3]','$_POST[image4]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> hello friends, while clicking the form all the information goes to database, I have one image upload field, when cliking the submit button, i would like 'image name' to go in database and file to go in /upload folder, i have tried this for hours and gave up, if anyone help me in this, i would be very greatful Hi I have a script Code: [Select] mkdir("myitems/images", 0777); chmod("myitems/images", 0777); if (!copy('downloads.zip', 'myitems/images/downloads.zip')) { echo "failed"; } when I run it, the folder is created and when checking folder permissions, it shows 777 but it fails on copying the file. if I manually create the folder "myitems/images/" and set it to 777, then when I run the script, the file is copied for some reason when I manually create the folder it works, but when PHP creates the folder, it fails on something any ideas? racking my brain trying to figure out why Dear all PHP experts need your help please as I'm very new the PHP. I found this php form script on the net which works perfectly but only uploads one file. I need to upload a second file and send it to a different folders and a different field on the database. I have viewed a number of site and changed the code a number of time without success I have put the code back to original script, can some one please show me what I need to do. Thanks <form action="upload.php" method="post" enctype="multipart/form-data"> <label>First Name</label><input type="text" name="fname" /><br /> <label>Last Name</label><input type="text" name="lname" /><br /> <label>Upload Image</label> <input type="file" name="image" /><br> <label>Spec</label> <input type="file" name="spec" /><br /> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> <input type="submit" id="submit" value="Upload" /> </form> Script function is_valid_type($file) { $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif"); if (in_array($file['type'], $valid_types)) return 1; return 0; } function showContents($array) { echo "<pre>"; print_r($array); echo "</pre>"; } $TARGET_PATH = "images/"; $fname = $_POST['fname']; $lname = $_POST['lname']; $image = $_FILES['image']; $fname = mysql_real_escape_string($fname); $lname = mysql_real_escape_string($lname); $image['name'] = mysql_real_escape_string($image['name']); $TARGET_PATH .= $image['name']; if ( $fname == "" || $lname == "" || $image['name'] == "" ) { $_SESSION['error'] = "All fields are required"; header("Location: index.php"); exit; } if (!is_valid_type($image)) { $_SESSION['error'] = "You must upload a jpeg, gif, or bmp"; header("Location: index.php"); exit; } if (file_exists($TARGET_PATH)) { $_SESSION['error'] = "A file with that name already exists"; header("Location: index.php"); exit; } if (move_uploaded_file($image['tmp_name'], $TARGET_PATH)) { $sql = "insert into people (fname, lname, filename,spec) values ('$fname', '$lname', '" . $image['name'] ."')"; $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error()); header("Location: images.php"); exit; } else { $_SESSION['error'] = "Could not upload file. Check read/write persmissions on the directory"; header("Location: index.php"); exit; } hi all, i have this music website and i have to upload every album under this folder "newsongs" ... in AlbumName folder i have normal quilty songs and HQ folder..under HQ folder i have High Quilty songs for each album. i have this coding which moves Album folder and normal quilty songs to other folder "songs" but i also want to move subfolder "HQ" and High Quilty songs with AlbumName folder for($i=0;$i<=$ct;$i++) { $alb=$alname[$i]; $cat=$catname[$i]; $albids=$albid[$i]; $fon=$folder_name[$i]; $tmp_name=$doc_root."newsongs/$fon"; $uploads_dir=$doc_root."songs/$cat/$fon"; if ($handle = opendir($tmp_name)) { /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { //echo "$file\n <br>"; if($file !=='..' and $file !=='.') { $song_path="songs/$cat/$fon/$file"; if(!is_dir("$tmp_name/$file") and (!is_dir("$uploads_dir/$file"))) { if(copy("$tmp_name/$file", "$uploads_dir/$file")) { $cp=1; $ext=substr($file,-4); if($ext=='.mp3') $insqry=mysql_query(" insert into tbl_songs set song_name='$file', album_id='$albids', artist_id='$artid', song_path='$song_path' "); unlink($tmp_name.'/'.$file); } else { echo "could not move songs "; } } } if($insqry) $msg="songs Added to the database"; else $msg="songs Not Added to the database"; } closedir($handle); thnx in advnce how to copy a full folder from source to destination using php please help me. I am unsuccessfully able to do the following:
User creates an account
After login, checks server if user has their own folder created
If doesn't exist, create it
Copy files from source_code to this new folder
My code does create a folder, but no files appear inside it.
Been trying to find an example with google search for the past 3 days with no luck.
I am running LAMP on Linux Mint OS to run my PHP webpages.
Can anyone tell me if issues with this section of coding?
<?php function wait_time($seconds) { $seconds = abs($seconds); if ($seconds < 1): usleep($seconds*1000000); else: sleep($seconds); endif; } $file1 = "blank.html"; $file2 = "channel_video.php"; $file3 = "clear_playlist.php"; $file4 = "confirm.html"; $file5 = "index.html"; set_time_limit(0); //prevent script from timing out $account = $_POST["account_name"]; $src = "source_code/"; $dst = $account."/"; echo 'Setting up your account page ->.'; mkdir($account, 0777, true); echo '.'; //create folder with full write permissions wait_time(2000); //wait 2 seconds before copying files over copy($src.$file1, $dst.$file1); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file2, $dst.$file2); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file3, $dst.$file3); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file4, $dst.$file4); echo '.'; wait_time(2000); //wait 2 seconds before copying files over copy($src.$file5, $dst.$file5); echo '.<- setup finished<br>'; ?>Thanks for any input you can provide. Hello, i am looking for a way to create a new folder when a customer uploads photos. I would like the folder to be named their email address. The photo uploader code is below: - [php <?php if($logged[scrollingpicturedisplay] == "yes"){ if($difference == "Gone"){ }else{ if($logged[spd_process] == "1"){ }else{ ?> <div id="spd"> <link href="/uploadify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/swfobject.js"></script> <script type="text/javascript" src="/jquery.uploadify.v2.1.4.min.js"></script> <script type="text/javascript"> $(function() { $('#custom_file_upload').uploadify({ 'uploader' : '/uploadify.swf', 'script' : 'uploadify.php?user=<?php echo("$logged[ip]");?>', 'cancelImg' : '/cancel.png', 'folder' : '/wuploads', 'multi' : true, 'auto' : true, 'fileExt' : '*.ZIP;*.zip;*.rar;*.jpg', 'queueID' : 'custom-queue', 'queueSizeLimit' : 1000, 'simUploadLimit' : 1000, 'removeCompleted': true, 'onSelectOnce' : function(event,data) { $('#status-message').text(data.filesSelected + ' files have been added to the queue.'); }, 'onAllComplete' : function(event,data) { $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.'); php/] and i think this is the code for the create new folder [php <? mkdir("/wuploads/{$slide['email']}"); ?> php/] The email is stored on the users database as the field 'email' i then would like it to put the photos in the created folder which i think is something like this [php 'folder' : '/wuploads/$slide['email']', php/] The pictures go into the correct folder if i use this, however the create folder part of it doesnt seem to work. any help would be great, thanks I'm using the following code to create a folder from a text field and works fine. I would like to upload 3 files in the created folder. <?php // set our absolute path to the directories will be created in: $path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/'; if (isset($_POST['create'])) { // Grab our form Data $dirName = isset($_POST['dirName'])?$_POST['dirName']:false; // first validate the value: if ($dirName !== false && preg_match('~([^A-Z0-9]+)~i', $dirName, $matches) === 0) { // We have a valid directory: if (!is_dir($path . $dirName)) { // We are good to create this directory: if (mkdir($path . $dirName, 0775)) { $success = "Your directory has been created succesfully!<br /><br />"; }else { $error = "Unable to create dir {$dirName}."; } }else { $error = "Directory {$dirName} already exists."; } }else { // Invalid data, htmlenttie them incase < > were used. $dirName = htmlentities($dirName); $error = "You have invalid values in {$dirName}."; } } ?> <html> <head><title>Make Directory</title></head> <body> <?php echo (isset($success)?"<h3>$success</h3>":""); ?> <h2>Make Directory on Server</h2> <?php echo (isset($error)?'<span style="color:red;">' . $error . '</span>':''); ?> <form name="phpMkDIRForm" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Enter a Directory Name (Alpha-Numeric only): <input type="text" value="" name="dirName" /><br /> <input type="submit" name="create" value="Create Directory" /> </form> </body> </html> Hi, ive recently created a gallery website and im happy with the way everything currently works. However the main drawback is the site uploads using a html webfom which is great for remote users or the odd image. However, as i want to mass upload my existing collection i will need the ability to read a selected folder and then to carry out all the same processes that existed from the existing html form upload. Im also using gdlibrary and checking file types to ensure they are within my allowed list, but im wondering if there are any other common security alerts i should be aware of to keep things a little bit safer if/when i publish outside of my LAN. So in a nut shell i need some assistance with changing my upload process to work for more than one file at a time, ideally by reading a folder, or at least reading X amount of files at a time - processing them then moving onto next batch of files in the list. Then the next part i need help with is checking/improving basic security of the system Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php $hostname='xxx'; $username='xxx'; $password='xxx'; $dbname='xxx; $usertable=xxx; $myconn=mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); if ((($_FILES["file"]["type"] =="image/gif") || ($_FILES["file"]["type"] =="image/jpeg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"]< 200000)) { if ($_FILES["file"]["error"] >0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br/>"; } else { if (file_exists("uploads/" . $_FILES["file"]["name"])) { echo "File already exists. Choose another name."; } else { move_uploaded_file($_FILES["file"]["tmp_name"],"uploads/" . $_FILES["file"]["name"]); } } } else { echo "Invalid file"; } $path="uploads/" . $_FILES["file"]["name"]; $desc=$_POST["desc"]; if (!myconn) { die ('Could not connect: ' . $mysql_error()); } $db_selected=mysql_select_db('xxx',$myconn); if (!$db_selected) { die ('Can\'t use xxxx : ' . mysql_error()); } mysql_query("INSERT INTO partners (desc,photopath,state) VALUES ('$desc','$path','$state')"); mysql_close($myconn); ?> </body> </html> This upload code is used for uploading a video file from html page, after recording via html5 screen <video></video>, however, ther file doesn't arrive in the uploads/ folder:
<?php foreach (array('video', 'audio') as $type) { if (isset($_FILES["${type}-blob"])) { $fileName = $_POST["${type}-filename"]; $uploadDirectory = 'uploads/' .rand(5,500).$fileName; if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $uploadDirectory)) { echo (" problem moving uploaded file"); } } } when uploaded from iPhone. So, I don't know how to see errors on iPhone. Folder permission is 755. php.ini max file size is 2024M, any ideas/solutions are appreciated.
I wonder whether someone may be able to help me please. I've put together the following script which saves user defined images to server folders using the Aurigma Image Uploader software. Code: [Select] <?php require_once 'Includes/gallery_helper.php'; require_once 'ImageUploaderPHP/UploadHandler.class.php'; $galleryPath = 'UploadedFiles/'; function onFileUploaded($uploadedFile) { global $galleryPath; $packageFields = $uploadedFile->getPackage()->getPackageFields(); $username=$packageFields["username"]; $locationid=$packageFields["locationid"]; $usernamefolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['username']); $locationfolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['locationid']); $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['folder']); $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; if (!is_dir($absGalleryPath)) mkdir($absGalleryPath, 0777, true); chmod($absGalleryPath, 0777); if (!is_dir($absGalleryPath . $dirName)) mkdir($absGalleryPath . $dirName, 0777, true); chmod($absGalleryPath . $dirName, 0777); if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) initGallery($absGalleryPath, $absThumbnailsPath, FALSE); $originalFileName = $uploadedFile->getSourceName(); $files = $uploadedFile->getConvertedFiles(); $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName); $sourceFile = $files[0]; if ($sourceFile) $sourceFile->moveTo($absGalleryPath . $sourceFileName); $thumbnailFileName = getSafeFileName($absThumbnailsPath, $originalFileName); $thumbnailFile = $files[1]; if ($thumbnailFile) $thumbnailFile->moveTo($absThumbnailsPath . $thumbnailFileName); $descriptions = new DOMDocument('1.0', 'utf-8'); $descriptions->load($absGalleryPath . 'files.xml'); $xmlFile = $descriptions->createElement('file'); // <-- please check the following line $xmlFile->setAttribute('name', $_POST['folder'] . '/' . $originalFileName); $xmlFile->setAttribute('source', $sourceFileName); $xmlFile->setAttribute('size', $uploadedFile->getSourceSize()); $xmlFile->setAttribute('originalname', $originalFileName); $xmlFile->setAttribute('thumbnail', $thumbnailFileName); $xmlFile->setAttribute('description', $uploadedFile->getDescription()); $xmlFile->setAttribute('username', $username); $xmlFile->setAttribute('locationid', $locationid); $xmlFile->setAttribute('folder', $dirName); $descriptions->documentElement->appendChild($xmlFile); $descriptions->save($absGalleryPath . 'files.xml'); } $uh = new UploadHandler(); $uh->setFileUploadedCallback('onFileUploaded'); $uh->processRequest(); ?> This code saves the files in the following structu UploadedFiles (Pre-existing folder) 'username' (Subfolder created dynamically on image upload if it doesn't already exist. This folder contains the 'location' folder) 'location' (Subfolder created dynamically on image upload if it doesn't already exist. This contains original image, 'files.xml' and 'Thumbnails' folder) 'Thumbnails' (Subfolder created dynamically on image upload if it doesn't already exist. This contains thumbnail of original image) I'm now trying to put together a script which creates an image gallery, with those images pertinent to the current user and location. The code below is the piece of my script which deals with the loading of the images. Code: [Select] <?php $galleryPath = 'UploadedFiles/'; $thumbnailsPath = $galleryPath . 'Thumbnails/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> The initial problem I had, was resolved from guidance I received on this site, and that was to find the correct 'realpath' of the 'Thumbnails' folder and 'files.xml' These are as follows: Quote /homepages/2/d333603417/htdocs/development/UploadedFiles/IRHM73/1 and Quote /homepages/2/d333603417/htdocs/development/UploadedFiles/IRHM73/1/Thumbnails with 'IRHM73' being the 'username' value and '1' the 'location' value. The problem I now have lies within this line of code: `$absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR;` Because the 'username' and 'location' are dynamic and hence contain different values for each user and location, I've found it impossible to find a way of creating the correct file path to open the 'Thumbnails' folder and 'files.xml'. I had tried this: Code: [Select] <?php $galleryPath = 'UploadedFiles/'; $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $usernamefolder . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR; $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR; $descriptions = new DOMDocument('1.0'); $descriptions->load($absGalleryPath . 'files.xml'); ?> But I receive the following error: DOMDocument::load() domdocument.load: I/O warning : failed to load external entity /homepages/2/d333603417/htdocs/development/UploadedFiles/'files.xml'; in /homepages/2/d333603417/htdocs/development/gallery.php on line 13 and line 13 is this: Code: [Select] $descriptions->load($absGalleryPath . 'files.xml'); I really am stumped with what to do next to get this to work. I appreciate that this is a fairly lengthy post, but thought it would be better to post all the information. I just wondered whether someone could perhaps take a look at this and let me know where I'm going wrong and how I can get it to work. Many thanks and regards After image is drop into container , I want to move copy of the original image to be move when original image dragend within container. I tried but it display copy image each time when original image dragend. can anyone help me?
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Prototype</title> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.2.min.js"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script> <style> body{padding:20px;} #container{ border:solid 1px #ccc; margin-top: 10px; width:350px; height:350px; } #toolbar{ width:350px; height:35px; border:solid 1px blue; } </style> <script> $(function(){ var $house=$("#house"); $house.hide(); var $stageContainer=$("#container"); var stageOffset=$stageContainer.offset(); var offsetX=stageOffset.left; var offsetY=stageOffset.top; var stage = new Kinetic.Stage({ container: 'container', width: 350, height: 350 }); var layer = new Kinetic.Layer(); stage.add(layer); var image1=new Image(); image1.onload=function(){ $house.show(); } image1.src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"; $house.draggable({ helper:'clone', }); $house.data("url","house.png"); // key-value pair $house.data("width","32"); // key-value pair $house.data("height","33"); // key-value pair $house.data("image",image1); // key-value pair $stageContainer.droppable({ drop:dragDrop, }); function dragDrop(e,ui){ var x=parseInt(ui.offset.left-offsetX); var y=parseInt(ui.offset.top-offsetY); var element=ui.draggable; var data=element.data("url"); var theImage=element.data("image"); var image = new Kinetic.Image({ name:data, x:x, y:y, image:theImage, draggable: true, dragBoundFunc: function(pos) { return { x: pos.x, y: this.getAbsolutePosition().y } } }); image.on("dragend", function(e) { var points = image.getPosition(); var image1 = new Kinetic.Image({ name: data, id: "imageantry", x: points.x+65, y: points.y, image: theImage, draggable: false }); layer.add(image1); layer.draw(); }); image.on('dblclick', function() { image.remove(); layer.draw(); }); layer.add(image); layer.draw(); } }); // end $(function(){}); </script> </head> <body> <div id="toolbar"> <img id="house" width=32 height=32 src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"><br> </div> <div id="container"></div> </body> </html> Edited by Biruntha, 08 January 2015 - 10:14 AM. So, I'm learning how to upload pictures into a system from my awesome PHP book. I've looked and looked through the script but I can't figure out whats wrong with it. Goal: The script is meant to save a full version of the image in the images folder and a thumbnail in the thumbnail folder. Bug: The full image does not appear in any folder, and the thumbnail is created but its put in the images folder. I've checked the GD library, and everything is supported. image_effect.php <?php //change this path to match your images directory $dir ='C:/x/xampp/htdocs/images'; //change this path to match your fonts directory and the desired font putenv('GDFONTPATH=' . 'C:/Windows/Fonts'); $font = 'arial'; // make sure the requested image is valid if (isset($_GET['id']) && ctype_digit($_GET['id']) && file_exists($dir . '/' . $_GET['id'] . '.jpg')) { $image = imagecreatefromjpeg($dir . '/' . $_GET['id'] . '.jpg'); } else { die('invalid image specified'); } // apply the filter $effect = (isset($_GET['e'])) ? $_GET['e'] : -1; switch ($effect) { case IMG_FILTER_NEGATE: imagefilter($image, IMG_FILTER_NEGATE); break; case IMG_FILTER_GRAYSCALE: imagefilter($image, IMG_FILTER_GRAYSCALE); break; case IMG_FILTER_EMBOSS: imagefilter($image, IMG_FILTER_EMBOSS); break; case IMG_FILTER_GAUSSIAN_BLUR: imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; } // add the caption if requested if (isset($_GET['capt'])) { imagettftext($image, 12, 0, 20, 20, 0, $font, $_GET['capt']); } //add the logo watermark if requested if (isset($_GET['logo'])) { // determine x and y position to center watermark list($width, $height) = getimagesize($dir . '/' . $_GET['id'] . '.jpg'); list($wmk_width, $wmk_height) = getimagesize('images/logo.png'); $x = ($width - $wmk_width) / 2; $y = ($height - $wmk_height) / 2; $wmk = imagecreatefrompng('images/logo.png'); imagecopymerge($image, $wmk, $x, $y, 0, 0, $wmk_width, $wmk_height, 20); imagedestroy($wmk); } // show the image header('Content-Type: image/jpeg'); imagejpeg($image, '', 100); ?> check_image.php <?php include 'db.inc.php'; //connect to MySQL $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //change this path to match your images directory $dir ='C:/x/xampp/htdocs/images'; //change this path to match your thumbnail directory $thumbdir = $dir . '/thumbs'; //change this path to match your fonts directory and the desired font putenv('GDFONTPATH=' . 'C:/Windows/Fonts'); $font = 'arial'; // handle the uploaded image if ($_POST['submit'] == 'Upload') { //make sure the uploaded file transfer was successful if ($_FILES['uploadfile']['error'] != UPLOAD_ERR_OK) { switch ($_FILES['uploadfile']['error']) { case UPLOAD_ERR_INI_SIZE: die('The uploaded file exceeds the upload_max_filesize directive ' . 'in php.ini.'); break; case UPLOAD_ERR_FORM_SIZE: die('The uploaded file exceeds the MAX_FILE_SIZE directive that ' . 'was specified in the HTML form.'); break; case UPLOAD_ERR_PARTIAL: die('The uploaded file was only partially uploaded.'); break; case UPLOAD_ERR_NO_FILE: die('No file was uploaded.'); break; case UPLOAD_ERR_NO_TMP_DIR: die('The server is missing a temporary folder.'); break; case UPLOAD_ERR_CANT_WRITE: die('The server failed to write the uploaded file to disk.'); break; case UPLOAD_ERR_EXTENSION: die('File upload stopped by extension.'); break; } } //get info about the image being uploaded $image_caption = $_POST['caption']; $image_username = $_POST['username']; $image_date = @date('Y-m-d'); list($width, $height, $type, $attr) = getimagesize($_FILES['uploadfile']['tmp_name']); // make sure the uploaded file is really a supported image $error = 'The file you uploaded was not a supported filetype.'; switch ($type) { case IMAGETYPE_GIF: $image = imagecreatefromgif($_FILES['uploadfile']['tmp_name']) or die($error); break; case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($_FILES['uploadfile']['tmp_name']) or die($error); break; case IMAGETYPE_PNG: $image = imagecreatefrompng($_FILES['uploadfile']['tmp_name']) or die($error); break; default: die($error); } //insert information into image table $query = 'INSERT INTO images (image_caption, image_username, image_date) VALUES ("' . $image_caption . '", "' . $image_username . '", "' . $image_date . '")'; $result = mysql_query($query, $db) or die (mysql_error($db)); //retrieve the image_id that MySQL generated automatically when we inserted //the new record $last_id = mysql_insert_id(); // save the image to its final destination $image_id = $last_id; imagejpeg($image, $dir . '/' . $image_id . '.jpg'); imagedestroy($image); } else { // retrieve image information $query = 'SELECT image_id, image_caption, image_username, image_date FROM images WHERE image_id = ' . $_POST['id']; $result = mysql_query($query, $db) or die (mysql_error($db)); extract(mysql_fetch_assoc($result)); list($width, $height, $type, $attr) = getimagesize($dir . '/' . $image_id . '.jpg'); } if ($_POST['submit'] == 'Save') { // make sure the requested image is valid if (isset($_POST['id']) && ctype_digit($_POST['id']) && file_exists($dir . '/' . $_POST['id'] . '.jpg')) { $image = imagecreatefromjpeg($dir . '/' . $_POST['id'] . '.jpg'); } else { die('invalid image specified'); } // apply the filter $effect = (isset($_POST['effect'])) ? $_POST['effect'] : -1; switch ($effect) { case IMG_FILTER_NEGATE: imagefilter($image, IMG_FILTER_NEGATE); break; case IMG_FILTER_GRAYSCALE: imagefilter($image, IMG_FILTER_GRAYSCALE); break; case IMG_FILTER_EMBOSS: imagefilter($image, IMG_FILTER_EMBOSS); break; case IMG_FILTER_GAUSSIAN_BLUR: imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); break; } // add the caption if requested if (isset($_POST['emb_caption'])) { imagettftext($image, 12, 0, 20, 20, 0, $font, $image_caption); } //add the logo watermark if requested if (isset($_POST['emb_logo'])) { // determine x and y position to center watermark list($wmk_width, $wmk_height) = getimagesize('images/logo.png'); $x = ($width - $wmk_width) / 2; $y = ($height - $wmk_height) / 2; $wmk = imagecreatefrompng('images/logo.png'); imagecopymerge($image, $wmk, $x, $y, 0, 0, $wmk_width, $wmk_height, 20); imagedestroy($wmk); } // save the image with the filter applied imagejpeg($image, $dir . '/' . $_POST['id'] . '.jpg', 100); //set the dimensions for the thumbnail $thumb_width = $width * 0.10; $thumb_height = $height * 0.10; //create the thumbnail $thumb = imagecreatetruecolor($thumb_width, $thumb_height); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height); imagejpeg($thumb, $dir . '/' . $_POST['id'] . '.jpg', 100); imagedestroy($thumb); ?> <html> <head> <title>Here is your pic!</title> </head> <body> <h1>Your image has been saved!</h1> <img src="images/<?php echo $_POST['id']; ?>.jpg" /> </body> </html> <?php } else { ?> <html> <head> <title>Here is your pic!</title> </head> <body> <h1>So how does it feel to be famous?</h1> <p>Here is the picture you just uploaded to our servers:</p> <?php if ($_POST['submit'] == 'Upload') { $imagename = 'images/' . $image_id . '.jpg'; } else { $imagename = 'image_effect.php?id=' . $image_id . '&e=' . $_POST['effect']; if (isset($_POST['emb_caption'])) { $imagename .= '&capt=' . urlencode($image_caption); } if (isset($_POST['emb_logo'])) { $imagename .= '&logo=1'; } } ?> <img src="<?php echo $imagename; ?>" style="float:left;"> <table> <tr><td>Image Saved as: </td><td><?php echo $image_id . '.jpg'; ?></td></tr> <tr><td>Height: </td><td><?php echo $height; ?></td></tr> <tr><td>Width: </td><td><?php echo $width; ?></td></tr> <tr><td>Upload Date: </td><td><?php echo $image_date; ?></td></tr> </table> <p>You may apply special options to your image below. Note: saving an image with any of the options applied <em>cannot be undone</em>.</p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <div> <input type="hidden" name="id" value="<?php echo $image_id;?>"/> Filter: <select name="effect"> <option value="-1">None</option> <?php echo '<option value="' . IMG_FILTER_GRAYSCALE . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_GRAYSCALE) { echo ' selected="selected"'; } echo '>Black and White</option>'; echo '<option value="' . IMG_FILTER_GAUSSIAN_BLUR . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_GAUSSIAN_BLUR) { echo ' selected="selected"'; } echo '>Blur</option>'; echo '<option value="' . IMG_FILTER_EMBOSS . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_EMBOSS) { echo ' selected="selected"'; } echo '>Emboss</option>'; echo '<option value="' . IMG_FILTER_NEGATE . '"'; if (isset($_POST['effect']) && $_POST['effect'] == IMG_FILTER_NEGATE) { echo ' selected="selected"'; } echo '>Negative</option>'; ?> </select> <br/><br/> <?php echo '<input type="checkbox" name="emb_caption"'; if (isset($_POST['emb_caption'])) { echo ' checked="checked"'; } echo '>Embed caption in image?'; echo '<br/><br/><input type="checkbox" name="emb_logo"'; if (isset($_POST['emb_logo'])) { echo ' checked="checked"'; } echo '>Embed watermarked logo in image?'; ?> <br/><br/> <input type="submit" value="Preview" name="submit" /> <input type="submit" value="Save" name="submit" /> </div> </form> </body> </html> <?php } ?> Any help appreciated. |