Jump to content

gsaldutti

Members
  • Posts

    32
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

gsaldutti's Achievements

Member

Member (2/5)

0

Reputation

  1. Just curious if anyone has an opinion on the following. I am building a site where alert messages will be necessary rather often (such as, "You must check at least 2 boxes", etc). I can't decide whether to have these alerts as standard javascript POPUP alerts (where the user has to click OK in order to continue), or just have the message appear on the actual page in red font or something. Anyone have an opinion either way?
  2. I am using this code below to check/uncheck a checkbox that is inside a DIV, upon clicking anywhere on the DIV... $("#checkbox").live('click', function(){ var $tc = $(this).find('input:checkbox:first'), tv = $tc.attr('checked'); $tc.attr('checked', !tv); }); I now would like to also have the background color change upon clicking anywhere on the DIV. For example, if they click the DIV, the checkbox would become checked AND the background of the DIV would become green. Then if clicked again, the checkbox would become unchecked and the background would go back to white. I got this far, and it does change the background to green upon clicking, but I can't figure out the part for "removing of background color". Any ideas who to accomplish that part? $("#checkbox").live('click', function(){ var $bg = $(this).css("background-color","green"); var $tc = $(this).find('input:checkbox:first'), tv = $tc.attr('checked'); $tc.attr('checked', !tv); });
  3. That is a definitely a good idea for my code, thanks. But in IE, it's still happening where I remove IMAGE-A and add IMAGE-B and it still displays IMAGE-A. Mindboggling. I assume clearstatcache() just needs to be at the top of the page one, but I tried it in seveal places throughout the code. Dropfaith mentioned that it could just be a funny thing that is happening on my local machine and once I upload the site to a public server it might work fine. If you think that is possibility, can someone help tell me how to get the GD library installed/enabled on a server so I can test this on my "live" site (or is that something my hosting company has to do?)
  4. I think that GD library thing is NOT enabled on my server, so I think I gotta figure out how to get that enabled (I made the entire PHPINFO show on that link I gave you earlier and I don't see "GD" anywhere). Anyway, here is the entire file (I tried to take out all the repetitive stuff to make it easier to browse through). Again, this is the only file and the action of the upload form is the page itself.... <?php header("Cache-Control: no-cache, must-revalidate"); require_once("includes/session.php"); require_once("includes/connection.php"); $success=""; $message=""; $badinsert=""; $deletemessage=""; $imagemessage=""; $removemessage=""; $wrongfiletype1=""; $nofilechosen1=""; $sessionid = session_id(); $file1name = "0-" . $sessionid . ".jpg"; if (isset($_POST['submit']) && $_POST['submit'] == "Upload Image 1") { if ($_FILES['userfile']['type'] == "image/pjpeg" || $_FILES['userfile']['type'] == "image/jpeg" ) { // This is the temporary file created by PHP $uploadedfile = $_FILES['userfile']['tmp_name']; // Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image list($width,$height) = getimagesize($uploadedfile); // For our purposes, I have resized the image to be // 600 pixels wide, and maintain the original aspect // ratio. This prevents the image from being "stretched" // or "squashed". If you prefer some max width other than // 600, simply change the $newwidth variable $newheight=200; $newwidth=($width/$height)*200; $tmp=imagecreatetruecolor($newwidth,$newheight); // this line actually does the image resizing, copying from the original // image into the $tmp image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // now write the resized image to disk. I have assumed that you want the // resized, uploaded image file to reside in the ./images subdirectory. $imagefolder = "upload/0-". $sessionid . ".jpg"; if (imagejpeg($tmp,$imagefolder,100)) { $imagemessage = "File is valid, and was successfully uploaded into FOLDER.\n"; $success="yes"; } else { $imagemessage = "Possible file upload attack!\n"; $success="no"; } imagedestroy($src); imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request // has completed. $isfile1 = "yes"; $filesize = $_FILES['userfile']['size']; } elseif ($_FILES['userfile']['type'] == "") { $nofilechosen1 = "You did not select a file"; } else { $wrongfiletype1 = "This image is not a JPEG image!!!!!!!!!"; } if($success=="yes"){ $query = "INSERT INTO images ( name, size ) VALUES ('" . $file1name . "','" . $filesize . "')"; $result = mysql_query($query, $connection); if ($result) { $message = "<p>The image was successfully submitted into the DATABASE. </p>"; } else { $message = "The image was NOT submitted."; $message .= "<br />" . mysql_error(); } } else { $badinsert = "<p>Didnt work!</p>"; } } else { } if (isset($_POST['submit']) && $_POST['submit'] == "Remove Image 1" ) { //need to delete image from the UPLOAD folder $removeimage = unlink("upload/$file1name"); if($removeimage) { $removemessage = "Actual Image was deleted from UPLOAD folder"; $isfile1="no"; } else { $removemessage = "Actual Image was NOT deleted!"; } //need to delete image info from the DATABASE $query = "DELETE FROM images WHERE name = '$file1name'"; $result = mysql_query($query, $connection); if ($result) { $deletemessage = "<p>The image was successfully DELETED. </p>"; } else { $deletemessage = "The image was NOT deleted."; $deletemessage .= "<br />" . mysql_error(); } } else { } if (file_exists("upload/$file1name")){ $isfile1 = "yes"; } else { $isfile1 = "no"; } ?> <html> <head> <meta http-equiv="pragma" content="no-cache" /> <title>Fill Script</title> <link href="smile.css" type="text/css" rel="stylesheet"> </head> <body> <div id="entirepage"> <?php echo $sessionid; echo "SUCCESS=" . $success; echo $imagemessage; echo $message; echo $badinsert; echo $deletemessage; echo $removemessage; echo "File 1 =" . $isfile1 . "<br>"; ?> <table WIDTH="980" CELLPADDING=5 CELLSPACING=5 BORDER=1 ALIGN=left> <tr > <td colspan=3>blah blah blah </td> </tr> <!-- START Upload Form #1-------------------------------------------> <tr> <td width=300 height=200> <?php if ($isfile1=="yes") { ?> <form action="uploadimage.php" method="POST"> <input type="submit" name="submit" value="Remove Image 1"> (So you can add a different image) </form> <?php } else { ?> <form action="uploadimage.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="5000000"> Upload Image: <input type="file" name="userfile" > <font size="1">Click browse to upload a file</font> <input type="submit" name="submit" value="Upload Image 1"> </form> <?php echo "<span class='error'>" . $nofilechosen1 . "</span>"; echo "<span class='error'>" . $wrongfiletype1 . "</span>"; } ?> </td> <td width=400 height=200><img src="http://localhost/pas/upload/<?php echo $file1name; ?>" /> </td> </tr> <!-- END Upload Form #1------------------------------------------> </table> <?php phpinfo(); ?> </div> </body> </html> <?php require_once("includes/footer.php"); ?>
  5. I hope it's that easy of a solution. Anyway, I uploaded my stuff to http://gdoot.com/imagetest/uploadimage.php but when I try to upload, naturally I get an error: Fatal error: Call to undefined function imagecreatefromjpeg() in /home/gdootcom/public_html/imagetest/uploadimage.php on line 50 I think that means my server doesn't have a certain image library or something, right? That could be a problem (unless it's easy to get it installed on the server). Any thoughts? ***Disregard the stuff above the Table. That's just testing stuff for my own reference
  6. Do you mean a link to actually do this on a public website? (I assume that's what you mean but just checking). I'm only doing this on my local machine so far but let me see if I can upload the files to my website....
  7. FYI, I created a new, separate page called "deleteimage.php" which does nothing but delete the image from my server and redirect back to the main page and it STILL will not work. The old images that are nowhere to be found on my server still display in the IE browser. Unbelievable. Anyway, thanks for all your help up to this point.
  8. I'm sure this is a dumb question but your code appears to redirect the user BEFORE the script to delete the image runs. It's probably PHP 101, but I'm guessing ALL code on the page runs even after the redirect. Is that right? Or am I missing something else?
  9. The meta tag didn't work either. Thanks to both of you for all the suggestions. I think I might be screwed
  10. Still no luck. MAN I HATE IE. I guess I'll have to submit all my upload-image forms to a different page and then redirect back (like dropfaiths) but I don't know if that is feasible with the way I want the site to work. Guess the only way I'll know is to try it. Hey Dropfaith, does your "other page" ever display in the user's browser, or does it simply process data and ALWAYS redirect back to the original page? I am using SESSIONS by the way, not sure if that matters
  11. That one didn't work either. Is there some way to test that the cache is not being used (i.e. to test that your header is doing it's job)? I totally trust that it should be doing what you say, but if I can confirm that it's not using the cache, then I'll know there must be something else in my code causing the issue. But like you said, it sounds like it's gotta be the cache causing the problem. I wish there was some PHP code that would recognize if someone was using IE and automatically close their IE, automatically install Firefox on their machine, and automatically re-open my site in Firefox
  12. Hey Genericnumber1, Do I just put that header at the top of the page, or does it need to go in the script that removes the actual image from my server? That's kind of rhetorical because I actually tried it in both spots and neither worked. What's even weirder that I forgot to mention is that in IE, I upload an image (we'll call it IMAGE-A) and then I hit "Remove Image" and IMAGE-A is removed from the server but it still shows in the browser. THEN, I upload another different image (we'll call it IMAGE-B) and it STILL SHOWS IMAGE-A in the browser, even though the only image on my server is IMAGE-B. I just don't get it. Makes no sense. Anyway, can you elaborate a bit on that "sleep" thing you mentioned? I've never heard of that but I'm willing to try anything.
  13. Sure, my code is below. FYI, I'm VERY new to PHP so I'm sure my code is not even close to being as efficient as it can be, so don't laugh too hard .... First, this is what my image upload form looks like... <!-- START Upload Form #1-------------------------------------------> <tr> <td width=300 height=200> <?php if ($isfile1=="yes") { ?> <form action="fillscript.php" method="POST"> <input type="submit" name="submit" value="Remove Image 1"> (So you can add a different image) </form> <?php } else { ?> <form action="fillscript.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="5000000"> Upload Image: <input type="file" name="userfile" > <font size="1">Click browse to upload a file</font> <input type="submit" name="submit" value="Upload Image 1"> </form> <?php } ?> </td> <td width=400 height=200><img src="http://localhost/pas/upload/<?php echo $file1name; ?>" /> </td> </tr> <!-- END Upload Form #1------------------------------------------> And here is the code that removes the image when they click the "Remove Image 1" button above... if (isset($_POST['submit']) && $_POST['submit'] == "Remove Image 1" ) { //to delete image from the UPLOAD folder $removeimage = unlink("upload/$file1name"); if($removeimage) { $removemessage = "Actual Image was deleted from UPLOAD folder"; $isfile1="no"; } else { $removemessage = "Actual Image was NOT deleted!"; } }
  14. This isn't completely a PHP question, but you guys are geniuses so I figured I'd ask and see if any of you knew... I have a PHP page that has several forms on it that upload images to my server. The action of all forms is to reload the same page the forms are on. As soon as the images are uploaded, the images appear on the user's browser (It's a simple script to put the image into a folder on my server and a simple echo of the file name to display it). This part works fine on both IE and Firefox. However, I have a "remove image" script as well and on IE only, when the user clicks "Remove image", the image is completely removed from my server fine (i.e. it truly no longer exists on my server), but the image still shows in the IE browser (Firefox works fine, meaning as soon as the user clicks "Remove image", the image disappears completely, as it should since it no longer exists on my server). If the IE user refreshes the page, then the image finally goes away, but I can't expect them do that. Is there a way to make IE work just like Firefox in respect to images disappearing if they truly don't exist, or is there some way to make a page refresh itself immediately after the page reloads with PHP? It just seems ridiculous that IE continues to display an image that no longer exists. Any thoughts would be appreciated greatly. Thank you...
×
×
  • 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.