Jump to content

skter4938

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

skter4938's Achievements

Member

Member (2/5)

0

Reputation

  1. Well no, basically what I want it for the admin to upload a picture. Then if the picture is bigger than 750px in width, for it to resize it accordingly, and save it. Then create a thumbnail from it. Basically my code does everything except resizing the original image.
  2. Hello there, Well basically I have a script that uploads an image and creates a sized thumbnail from it. I can't figure out how I can also resize the image if it is too big. Say I have an image that is 400x856 px, well since the width is bigger than my wanted 750px, I would like the image to resize dinamically keeping the same ratio. Here is my code for the upload, if someone could help me out that would be great. <?php //define a maxim size for the uploaded images define ("MAX_SIZE","5000"); // define the width and height for the thumbnail // note that theese dimmensions are considered the maximum dimmension and are not fixed, // because we have to keep the image ratio intact or it will be deformed define ("WIDTH","75"); define ("HEIGHT","25"); // this is the function that will create the thumbnail image from the uploaded image // the resize will be done considering the width and height defined, but without deforming the image function make_thumb($img_name,$filename,$new_w,$new_h) { //get image extension. $ext=getExtension($img_name); //creates the new image using the appropriate function from gd library if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $src_img=imagecreatefromjpeg($img_name); if(!strcmp("png",$ext)) $src_img=imagecreatefrompng($img_name); if(!strcmp("gif",$ext)) $src_img=imagecreatefrompng($img_name); //gets the dimmensions of the image $old_x=imageSX($src_img); $old_y=imageSY($src_img); // next we will calculate the new dimmensions for the thumbnail image // the next steps will be taken: // 1. calculate the ratio by dividing the old dimmensions with the new ones // 2. if the ratio for the width is higher, the width will remain the one define in WIDTH variable // and the height will be calculated so the image ratio will not change // 3. otherwise we will use the height ratio for the image // as a result, only one of the dimmensions will be from the fixed ones $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; } // we create a new image with the new dimmensions $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); // resize the big image to the new created one imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); // output the created image to the file. Now we will have the thumbnail into the file named by $filename if(!strcmp("png",$ext)) imagepng($dst_img,$filename); else imagejpeg($dst_img,$filename); //destroys source and destination images. imagedestroy($dst_img); imagedestroy($src_img); } // This function reads the extension of the file. // It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. If the error occures the file will not be uploaded. $errors=0; // checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; // if it is not empty if ($image) { // get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); // get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); // if it is not a known extension, we will suppose it is an error, print an error message //and will not upload the file, otherwise we continue if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { echo 'Unknown extension!<br>'; $errors=1; } else { // get the size of the image in bytes // $_FILES[\'image\'][\'tmp_name\'] is the temporary filename of the file in which //the uploaded file was stored on the server $size=getimagesize($_FILES['image']['tmp_name']); $sizekb=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($sizekb > MAX_SIZE*1024) { echo 'The file you are uploading is far too large<br>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="gd/imgupload/images/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); //we verify if the image has been uploaded, and print error instead if (!$copied) { echo 'Copy unsuccessfull!<br>'; $errors=1; } else { // the new thumbnail image will be placed in images/thumbs/ folder $thumb_name='gd/imgupload/images/thumbs/'.$image_name; // call the function that will create the thumbnail. The function will get as parameters //the image name, the thumbnail name and the width and height desired for the thumbnail $thumb=make_thumb($newname,$thumb_name,WIDTH,HEIGHT); }} }} //If no errors registred, print the success message and show the thumbnail image created if(isset($_POST['Submit']) && !$errors) { echo "Upload successfull.<br>"; echo '<img src="'.$thumb_name.'">'; } ?>
  3. Hello. I have this question that I cannot possibly get working. Alright, let me explain. I have a button which is called "bookmark". When that button is clicked, it goes to a page called "bookmark.php" and then executes a peice of code which adds that file to you bookmarks. Now what I want to do is have a image named "bookmark" which will be a little '+' sign. When that image is clicked, the bookmark.php code is executed BUT WITHOUT CHANGING THE PAGE. aka using Ajax. and if that file has already been bookmarked the image will be a little '-' sign. So here is my bookmark.php code: <? require_once("include/main.php"); dbconn(); loggedinorreturn(); function bark($msg) { stdhead(); stdmsg("w00t!", $msg); stdfoot(); exit; } if (!isset($_GET[file])) bark ("Faild ... No file selected"); if ((get_row_count("bookmarks", "WHERE userid=$CURUSER[id] AND fileid = $_GET[file]")) > 0) bark("Already bookmarked $_GET[file]"); mysql_query("INSERT INTO bookmarks (userid, fileid) VALUES ($CURUSER[id], $_GET[file])") or sqlerr(__FILE__,__LINE__); bark ("Successfully bookmarked"); ?> and here is the image of the way it goes to the boomark.php page. the little + sign is the bookmark.php button thing, and the arrow is the download button. -Artem
  4. Ok so... I made this site. Where my friend and I draw comics and put them up. They are funny. If you would like to see them here is the link http://www.chilledsaladfork.com/comics/ Anyways. Right now we are trying to expand our community to a greater limit. We need moderators and people to post so the mods can moderate you :) So please join the forums and post away! Here is the link to the site: http://www.chilledsaladfork.com I know the index page doesn't work, I am still working on it :) Thanks, Artem
  5. hah. Is there anyway you can possibly help me out with bringing a query? Thanks, Artem Artemov
  6. Hello out there. I currently have a vbulletin board up on my site. I already asked at the main site, and everywhere, but no help. I want the News and Announcements forum, to show up on my index page as the content. Like when an admin posts something in that forum, that post will show up on the main page. Could this be done in vbulletin? Thanks, Artem
  7. It tells me that there is an error now. Here is the full code to the contact.php. Can you look over it to see waht the error is? [code]<?php session_start(); //Email Validation function checkEmail($email) {   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email))   {       return FALSE;   }   list($Username, $Domain) = split("@",$email);   if(@getmxrr($Domain, $MXHost))   {       return TRUE;   }   else   {       if(@fsockopen($Domain, 25, $errno, $errstr, 30))       {         return TRUE;       }       else       {         return FALSE;       }   } } // get posted data into local variables switch ($_POST['EmailTo']){   case "artem":       $emailto = "skter4938@gmail.com";       break;   case "kris":       $emailto = "skter4938@hotmail.com";       break; } $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $Name = Trim(stripslashes($_POST['Name'])); $Subject = Trim(stripslashes($_POST['Subject'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if(checkEmail($EmailFrom) == FALSE){ $error_msg[] = "Please enter in a valid email address."; } if (Trim($Name)==""){ $error_msg[] = "Please enter in a name."; } if (Trim($Subject)=="") { $error_msg[] = "Please enter in a subject."; } if (Trim($Message)==""){ $error_msg[] = "Please enter in a message."; } //triggers error message if ($error_msg) { $_SESSION['error_msg'] = $error_msg; header ('Location: index.php'); exit(); } //sends email else { $Body = "You have a new email from $Name.\n\n Reply to $EmailFrom.\n\n $Name says,\n $Message"; $success = mail($EmailTo, $Subject, $Body); } //redirect to success page if ($success){   print "<meta http-equiv=\"refresh\" content=\"0;URL=../index.php\">"; } else{   print "Email could not be sent due to errors. Please email the <a href='mailto:skter4938@gmail.com>webmaster</a>."; } ?>[/code]
  8. How do I assign that to $emailto?
  9. Hello there. I have a contact form made, but I want the sender to choose to whome he wants to send it to, with a selection box. something like http://www.explosm.net/contact/ Here is the code in the contact.php part, where the form is processed. [code]// get posted data into local variables $EmailTo = "skter4938@gmail.com"; $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $Name = Trim(stripslashes($_POST['Name'])); $Subject = Trim(stripslashes($_POST['Subject'])); $Message = Trim(stripslashes($_POST['Message'])); [/code] And this is the accual form code [code]<form method="POST" action="contact.php"> <select name="emailto">     <option value="artem" selected>Artem Artemov</option>       <option value="kris">Kris Mobayeni</option>   </select> <p><label for="Name">Name</label><br /> <input id="Name" name="Name" type="text" tabindex="1" size="30" /></p> <p><label for="EmailFrom">Email</label><br /> <input id="EmailFrom" name="EmailFrom" type="text" tabindex="2" size="30" /></p> <p><label for="Subject">Subject</label><br /> <input id="Subject" name="Subject" type="text" tabindex="3" size="30" /></p> <p><label for="words">Message</label><br /> <textarea name="Message" tabindex="5" rows="10" cols="24" style="width:300px;"></textarea></p> <input type="submit" name="post" id="post" value="&nbsp;Send&nbsp;" />&nbsp;&nbsp;<input type="reset" value="&nbsp;Reset&nbsp;" /> </form>[/code] could you please help out?
  10. Hello there young lads. I was recently hired for a large project. It involves me creating a graphic design for a website that is something like cnet.com. It consists of 40+ pages. I have to design every single page. Well I have one problem. I do not know how much to charge. The client says he absolutely loves my example design that I showed him. How much should I charge him. Keep in mind, that this project will take me a good amount of time. Thank you, Artem
  11. [!--quoteo(post=386388:date=Jun 21 2006, 09:52 AM:name=steviewdr)--][div class=\'quotetop\']QUOTE(steviewdr @ Jun 21 2006, 09:52 AM) [snapback]386388[/snapback][/div][div class=\'quotemain\'][!--quotec--] Its not too bad. Its a little dark for my liking with the text a shade on the small side. The Nav menu is nice, the a:hovers and all - HOWEVER it is a little TOO subtle with the white text on the NAV corresponding to the page you are on. The corresponding Tab on the NAV bar should clearly show when you are on the assocaited page. Either make the text more white, bold it, or but the colour bottom border on it. The "web2design" text should be an Image IMO. - it would look better rather than aliased text. Id like to see a better header image also. Your about page is broken in IE6 !! Your news page is also broken in IE6 !! And as for [a href=\"http://www.chilledsaladfork.com/\" target=\"_blank\"]http://www.chilledsaladfork.com/[/a] - 8.6 megs!! Quite a lot for that FLASH animation. Rgds, Steve [/quote] Thank you for the comments [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]. I will try and make my navigation better, have the orange underline stay when it is on that page. I didn't want to use lots of images, because then if I needed to change something I could just edit the text. What do you mean by a header image? Are you talking about the logo or what [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] I have no idea why the about page is broken in IE6..weird.. but I will try and fix that. I will fix the news page right away. And the flash site, I know I know, a long loading time, that's because there is a 14 minute song [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Thank you for the comments and critique. I really appreciate it [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [!--quoteo(post=386404:date=Jun 21 2006, 10:28 AM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ Jun 21 2006, 10:28 AM) [snapback]386404[/snapback][/div][div class=\'quotemain\'][!--quotec--] You have tables. Why do you have tables? Tables are bad for layout. Also, on your "Book" page (I was expecting a published book information page, not a guestbook. Why do you even have one there?) your input fields stick out of the rounded box. [/quote] I decided to use tables because it was easier on me. I know it's bad and all...but if an average person looks at it, he cannot tell the difference [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] I have the guestbook so people can leave their comments about my site. I just wanted that little feature. And waht browser are you using? because I checked the guestbook page in firefox and IE and the input feilds look fine. Thank you for the comments and critique. I really appreciate it [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  12. Hello there people. I finally completed my 3rd redesign of my website. [a href=\"http://www.webtodesign.net\" target=\"_blank\"]www.webtodesign.net[/a] It is an online portfolio of all of my work. Comments and critique is appreciated [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  13. That it is [b]EDIT[/b] I got it to work. Thanks guys :D
×
×
  • 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.