Jump to content

squizz

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

squizz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ok.... so i finally get a dynamic images gallery running by putting them in manually then added an upload ability so i could do it from my admin page. (all done without a database). im just stuck trying to get a way to add a comment with my uploaded image. my code for the upload <?php $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.doc','.pdf'); $max_filesize = 524288; $upload_path = 'images/gallery/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file <a href="index1.php?page=art&style=default">here</a>'; . else echo 'There was an error during the file upload. Please try again.'; ?> how can i add a comment with it?
  2. *bump* please it problem is rateling my brain i dont know why its not loading the images
  3. hmmm still uploading blank/broken images images no echo came up saying its couldnt upload it
  4. I know its a bit late of a reply but i been busy sorry i think this is the code function uploadImage($inputName, $uploadDir) { $image = $_FILES[$inputName]; $imagePath = ''; $thumbnailPath = ''; // if a file is given if (trim($image['tmp_name']) != '') { $ext = substr(strrchr($image['name'], "."), 1); // generate a random new file name to avoid name conflict // then save the image under the new file name $imagePath = md5(rand() * time()) . ".$ext"; $result = move_uploaded_file($image['tmp_name'], $uploadDir . $imagePath); if ($result) { // create thumbnail $thumbnailPath = md5(rand() * time()) . ".$ext"; $result = createThumbnail($uploadDir . $imagePath, $uploadDir . 'thumbnail/' . $thumbnailPath, THUMBNAIL_WIDTH); // create thumbnail failed, delete the image if (!$result) { unlink($uploadDir . $imagePath); $imagePath = $thumbnailPath = ''; } else { $thumbnailPath = $result; } } else { // the image cannot be uploaded $imagePath = $thumbnailPath = ''; } } return array('image' => $imagePath, 'thumbnail' => $thumbnailPath); } /* Create a thumbnail of $srcFile and save it to $destFile. The thumbnail will be $width pixels. */ function createThumbnail($srcFile, $destFile, $width, $quality = 75) { $thumbnail = ''; if (file_exists($srcFile) && isset($destFile)) { $size = getimagesize($srcFile); $w = number_format($width, 0, ',', ''); $h = number_format(($size[1] / $size[0]) * $width, 0, ',', ''); $thumbnail = copyImage($srcFile, $destFile, $w, $h, $quality); } // return the thumbnail file name on sucess or blank on fail return basename($thumbnail); } /* Copy an image to a destination file. The destination image size will be $w X $h pixels */ function copyImage($srcFile, $destFile, $w, $h, $quality = 75) { $tmpSrc = pathinfo(strtolower($srcFile)); $tmpDest = pathinfo(strtolower($destFile)); $size = getimagesize($srcFile); if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg") { $destFile = substr_replace($destFile, 'jpg', -3); $dest = imagecreatetruecolor($w, $h); //imageantialias($dest, TRUE); } elseif ($tmpDest['extension'] == "png") { $dest = imagecreatetruecolor($w, $h); //imageantialias($dest, TRUE); } else { return false; } switch($size[2]) { case 1: //GIF $src = imagecreatefromgif($srcFile); break; case 2: //JPEG $src = imagecreatefromjpeg($srcFile); break; case 3: //PNG $src = imagecreatefrompng($srcFile); break; default: return false; break; } imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); switch($size[2]) { case 1: case 2: imagejpeg($dest,$destFile, $quality); break; case 3: imagepng($dest,$destFile); } return $destFile; }
  5. the paths have been defined and i got the files they should go to but they not seem to upload there. yet my database says they have been stored.
  6. $filePath is defined in the config.php with define('ALBUM_IMG_DIR', 'images/album/'); define('GALLERY_IMG_DIR', 'images/gallery/'); define('THUMBNAIL_WIDTH', 100); i have these file set on my server had a look the upload isn't going to the files (they're empty) if(isset($_POST['txtName'])) { $albumName = $_POST['txtName']; $albumDesc = $_POST['mtxDesc']; $imgName = $_FILES['fleImage']['name']; $tmpName = $_FILES['fleImage']['tmp_name']; $ext = strrchr($imgName, "."); $newName = md5(rand() * time()) . $ext; $imgPath = ALBUM_IMG_DIR . $newName; //it says its going there but there is no image in the file $result = createThumbnail($tmpName, $imgPath, THUMBNAIL_WIDTH); if (!$result) { echo "Error uploading file"; exit; } if (!get_magic_quotes_gpc()) { $albumName = addslashes($albumName); $albumDesc = addslashes($albumDesc); } $query = "INSERT INTO tbl_album (al_name, al_description, al_image, al_date) VALUES ('$albumName', '$albumDesc', '$newName', NOW())"; mysql_query($query) or die('Error, add album failed : ' . mysql_error()); echo "<script>window.location.href='adbum.php?page=list-album';</script>"; exit; }
  7. im trying to view it in an album... i followed a tutorial and it says its uploading and viewing but i get this... with this error from safari Warning: filesize() [function.filesize]: Stat failed for /images/album/578732c0667c44c19e489f94f0a3c57b.jpg (errno=2 - No such file or directory) in /viewImage.php on line 31 Warning: Cannot modify header information - headers already sent by (output started at /viewImage.php:31) in /viewImage.php on line 31 Warning: Cannot modify header information - headers already sent by (output started at /viewImage.php:31) in /viewImage.php on line 34 Warning: readfile(/images/album/578732c0667c44c19e489f94f0a3c57b.jpg) [function.readfile]: failed to open stream: No such file or directory in /viewImage.php on line 37
  8. im having trouble viewing images from the database <?php if (!isset($_GET['type']) || !isset($_GET['name'])) { exit; } $type = $_GET['type']; $name = $_GET['name']; include 'library/config.php'; if ($type == 'album') { $filePath = ALBUM_IMG_DIR . $name; } else if ($type == 'glimage') { $filePath = GALLERY_IMG_DIR . $name; } else if ($type == 'glthumbnail') { $filePath = GALLERY_IMG_DIR . 'thumbnail/' . $name; } else { // invalid image type exit; } header("Content-length: " . filesize($filePath)); header("Content-type: image/" . substr($name, strpos($name, '.') + 1)); readfile($filePath); ?>
  9. Hi php freaks I am fairly new to php and mysql and have been making a dynamic website (with a CMS) for a college. I found http://www.php-mysql-tutorial.com/index.php and have been working through the tutorials there. It has helped me alot, however i found myself stuck making the image gallery. I followed the tutorial and it still dose not work. I would like to know if anyone had anymore different solutions or tutorials that will help Thanks ^^ another thing I found is that the user authentication for login in through the DB dose not work too even if you enter the correct id and password(my tutor had this problem also).
  10. ok i been working on my website at my college and they only allow safari browser and my site worked in it but in ff. it HAS ot be liquid and must be strict. when i take it into ff there is no background and when i get to image page the rollover it works fine but the images arnt scaling to be what i defined them. first the background problem <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title> Welcome to Hack Productions</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css.css" /> </head> <body> <div id="header"> <img src= "images/menubars/banner2.jpg" alt= "Hack Production" /> </div> <ul class="glossymenu"> <li class="current"><a href="index.html"><b>Home</b></a></li> <li><a href="gallery.html"><b>Gallery</b></a></li> <li><a href="!"><b>Blog</b></a></li> <li><a href="info.html"><b>Info</b></a></li> <li><a href="links.html"><b>Links</b></a></li> </ul> <div id="col2"><h2>Content</h2> <p class="treetop">some text</p> </div> </body> </html> and css <style type="text/css"> h1 { font-family: geneva, arial, helvetica, san serif; font-size:16px; color:#ffffff; } h2 { font-family: geneva, arial, helvetica, san serif; font-size:13px; color:#333333; } h3 { font-family: geneva, arial, helvetica, san serif; font-size:12px; color:#000000; } body { background-image: url(images/menubars/banner1.jpg); font-family: verdana, arial, helvetica, sans-serif; text-align:center; margin:0; padding:0; min-width: 760px; } p { font-family: geneva, arial, helvetica, san serif; font-size:13px; } p.treetops { font-family: geneva, arial, helvetica, san serif; font-size: 10%; text-align:justify; color:#333333; } #header { font-size:80%; float: left; text-align: left; width: 100%; background: url(images/menubars/banner1.jpg) repeat-x bottom left; } #col1 { font-size:80%; float: left; width: 100%; margin-left: 2.5px; margin-right 2.5px; margin-bottom: 1px; border:1px; border-style:solid; border-color:#000000; background-color:#CECCAD; } #images { font-size:80%; float: left; width: 14%; border:1px; border-style:solid; border-color:#000000; background-color:#CECCAD; } #col2 { font-size:80%; margin-left: 15%; float: left; width: 70%; border:1px; border-style:solid; border-color:#000000; background-color:#cccccc; padding-bottom: 40px } .glossymenu{ float:left; width:100%; position: relative; padding: 0 0 0 34px; margin: 0 auto 0 auto; background: url(images/menubars/menuo_bg.gif) repeat-x; height: 46px; list-style: none; } .glossymenu li{ float:left; } .glossymenu li a{ float: left; display: block; color:#000; text-decoration: none; font-family: sans-serif; font-size: 13px; font-weight: bold; padding:0 0 0 16px; height: 46px; line-height: 46px; text-align: center; cursor: pointer; } .glossymenu li a b{ float: left; display: block; padding: 0 24px 0 8px; } .glossymenu li.current a, .glossymenu li a:hover{ color: #fff; background: url(images/menubars/menuo_hover_left.gif) no-repeat; background-position: left; } .glossymenu li.current a b, .glossymenu li a:hover b{ color: #fff; background: url(images/menubars/menuo_hover_right.gif) no-repeat right top; } .cssform p{ width: 300px; clear: left; margin: 0; padding: 5px 0 8px 0; padding-left: 155px; border-top: 1px dashed gray; height: 1%; } .cssform label{ font-weight: bold; float: left; margin-left: -155px; width: 150px; } .cssform input[type="text"]{ width: 180px; } .cssform textarea{ width: 250px; height: 150px; } .threepxfix{ margin-left: 3px; } </style> then why my image gallery, why my images arnt scaling <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Gallery</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css1.css" /> </head> <body> <div id="header"> <img src= "images/menubars/banner2.jpg" alt= "Hack Production" /> </div> <ul class="glossymenu"> <li><a href="index.html"><b>Home</b></a></li> <li class="current"><a href="gallery.html"><b>Gallery</b></a></li> <li><a href="!"><b>Blog</b></a></li> <li><a href="info.html"><b>Info</b></a></li> <li><a href="links.html"><b>Links</b></a></li> </ul> <div id="images"> <ul class="glossymenuside"> <li class="current"><a href="scrap.html"><b>Scrap Artwork</b></a></li> <li><a href="colour.html"><b>Finished work</b></a></li> <li><a href="digital.html"><b>Digital work</b></a></li> <li><a href="flash.html"><b>Animations</b></a></li> </ul> </div> <div id="col2"><h2>Scrap images</h2> <div class="gallerycontainer"> <a class="thumbnail" href="images/scrap/chibi uchha.jpg"><img src="images/scrap/chibi uchha.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/chibi uchha.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/comic 1.1.jpg"><img src="images/scrap/comic 1.1.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/comic 1.1.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/comic 1.2.jpg"><img src="images/scrap/comic 1.2.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/comic 1.2.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/cyber fairy.jpg"><img src="images/scrap/cyber fairy.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/cyber fairy.jpg" /><br />Just a scrap</span></a> <br /> <a class="thumbnail" href="images/scrap/skech7.jpg"><img src="images/scrap/skech7.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/skech7.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/goth.jpg"><img src="images/scrap/goth.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/goth.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/goth-line-art.jpg"><img src="images/scrap/goth-line-art.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/goth-line-art.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/img006.jpg"><img src="images/scrap/img006.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/img006.jpg" /><br />Just a scrap</span></a> <br /> <a class="thumbnail" href="images/scrap/img009.jpg"><img src="images/scrap/img009.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/img009.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/img010.jpg"><img src="images/scrap/img010.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/img010.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/maho rail.jpg"><img src="images/scrap/maho rail.jpg" height="10%" alt= "Hack Production" /><span><img src="images/scrap/maho rail.jpg" /><br />Just a scrap</span></a> <a class="thumbnail" href="images/scrap/sasuka.jpg"><img src="images/scrap/sasuka.jpg" height="10%"" alt= "Hack Production" /><span><img src="images/scrap/sasuka.jpg" /><br />Just a scrap</span></a> </div> </div> </body> </html> this ones css <style type="text/css"> h1 { font-family: geneva, arial, helvetica, san serif; font-size:16px; color:#ffffff; } h2 { font-family: geneva, arial, helvetica, san serif; font-size:13px; color:#333333; } h3 { font-family: geneva, arial, helvetica, san serif; font-size:12px; color:#000000; } body { background: url(images/menubars/banner1.jpg); font-family: verdana, arial, helvetica, sans-serif; text-align:center; margin:0; padding:0; min-width: 760px; } p { font-family: geneva, arial, helvetica, san serif; font-size:13px; color:#000000; } p.treetops { font-family: geneva, arial, helvetica, san serif; font-size: 10%; text-align:justify; color:#333333; } .glossymenu{ float:left; width:100%; position: relative; padding: 0 0 0 34px; margin: 0 auto 0 auto; background: url(images/menubars/menuo_bg.gif) repeat-x; height: 46px; list-style: none; } .glossymenu li{ float:left; } .glossymenu li a{ float: left; display: block; color:#000; text-decoration: none; font-family: sans-serif; font-size: 13px; font-weight: bold; padding:0 0 0 16px; height: 46px; line-height: 46px; text-align: center; cursor: pointer; } .glossymenu li a b{ float: left; display: block; padding: 0 24px 0 8px; } .glossymenu li.current a, .glossymenu li a:hover{ color: #fff; background: url(images/menubars/menuo_hover_left.gif) no-repeat; background-position: left; } .glossymenu li.current a b, .glossymenu li a:hover b{ color: #fff; background: url(images/menubars/menuo_hover_right.gif) no-repeat right top; } #header { font-size:80%; float: left; text-align: left; width: 100%; background: url(images/menubars/banner1.jpg) repeat-x bottom left; } #col1 { font-size:80%; float: left; width: 100%; margin-left: 2.5px; margin-right 2.5px; margin-bottom: 1px; border:1px; border-style:solid; border-color:#000000; background-color:#CECCAD; } #images { font-size:80%; float: left; width: 15%; border-color:#000000; } #col2 { font-size:80%; float: left; width: 70%; border:1px; border-style:solid; border-color:#000000; background-color:#cccccc; } .glossymenuside{ list-style-type: none; margin: 0; padding: 0; width: 100%; } .glossymenuside li a{ background: url(images/menubars/glossyback3.gif) no-repeat; background-color: #d3dadf; color: black; display: block; width: auto; text-decoration: none; } .glossymenuside li a{ width: 100%; } .glossymenuside li a:visited, .glossymenu li a:active{ color: black; } .glossymenuside li a:hover{ background-image: url(images/menubars/glossyback1.gif); color: white; background-color: #e46323; } .glossymenuside li.current a, .glossymenuside li a:hover{ background-color: #e46323; color: white; } .gallerycontainer{ position: relative; padding: 0 55% 0 0; padding-bottom: 400px; } .thumbnail img{ border: 1px solid white; margin: 0 5px 5px 0; } .thumbnail:hover{ background-color: transparent; } .thumbnail:hover img{ border: 1px solid blue; } .thumbnail span{ position: absolute; background-color: lightyellow; padding: 5px; border: 1px dashed gray; visibility: hidden; color: black; text-decoration: none; } .thumbnail span img{ border-width: 0; padding: 2px; width: 98%; } .thumbnail:hover span{ visibility: visible; top: 0; left: 45%; z-index: 50; } </style> thank if you can help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.