Jump to content
Larry Ullman's Book Forums

shousommers20

Members
  • Posts

    17
  • Joined

  • Last visited

shousommers20's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Why can I not download image files the end with .JPG? Is there a way to change that? I have many images that end with .JPG. $page_title = 'Upload images'; include($_SERVER["DOCUMENT_ROOT"]."/login/includes/header_upload_image.html"); $message = array(); if($_SERVER['REQUEST_METHOD'] == 'POST'){ if(isset($_FILES['upload'])){ $allowed = array('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/jpg', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'); if(in_array($_FILES['upload']['type'], $allowed)){ if(move_uploaded_file($_FILES['upload']['tmp_name'], $_SERVER['DOCUMENT_ROOT']."/login/uploads/{$_FILES['upload']['name']}")){ $message[0] = '<p><em> The file has been uploaded!</em></p>'; } } else{ $message[1] = '<p>Please upload a JPEG or PNG image.</p>'; } } if(file_exists($_FILES['upload']['tmp_name']) && is_file($_FILES['upload']['tmp_name'])){ unlink($_FILES['upload']['tmp_name']); } } ini_set("display_errors", 1); ?> <div id="header"> <div id="greeting"> <?php echo '<p>Hello, '.$_SESSION['first_name'].'!</p>'; ?> </div> <a id="view_images" href="http://funwithlola.com/modification_page.php">View Images</a> <a id="logout" href="logout.php">Logout</a> </div> <div id="middle"> <div id="upload"> <form enctype="multipart/form-data" action="upload_image.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <fieldset> <legend>Select a JPEG or PNG image of 512mb or smaller to be uploaded:</legend> <p><b>File:</b> <input type="file" name="upload" /></p> <?php if(isset($message)) echo $message[0].$message[1]; ?> </fieldset> <div align="center"> <input type="submit" name="submit" value="Upload" /> </div> </div> </div> </form> </body> </html>
  2. I'm getting this error. Fatal error: Call to undefined function delete() I'm trying to delete a photo. echo " <li class=\"image_list\"> <a href=\"javascript: create_window('$image_name', $image_size[0], $image_size[1])\" > <img src=\"/login/uploads/$image_name\" width=\"200\" height=\"200\" /> </a> <form action=\"modification_page.php\" method=\"post\"> <input class=\"delete_photo\" type=\"submit\" name=\"delete\" value=\"'$image_name'\" /> </form> </li>"; if($_SERVER['REQUEST_METHOD'] == 'POST'){ $delete = "/login/uploads/{$_POST['delete']}"; if(isset($_POST['delete'])){ delete($_SERVER["DOCUMENT_ROOT"].$delete); } else{ echo '<p> Error: Please refer to the website administrator.<p>'; }
  3. Thank you for your insight! Although I have done many research on this, from what you said gives me a lot to think about.
  4. Hartley, I've notice that you live in Yokohama, Japan from the description under your profile picture. I've been to Japan many times and I love it there. I'm half Japanese and although I can't read and write Japanese fairly proficiently, I can have a decent conversation. Even to say that, I doubt I can work at a Japanese company, so what I wanted to ask is if there are many web development(mainly PHP) jobs around the Yokohama and Tokyo area?
  5. I guess the term I'm using is a little off. What I mean is, can I use that method to display other user pictures in a social networking site like facebook or myspace? Hey do you know what Larry mean by the sentence below? What does he mean by independent? function check_login($dbc, $email = '', $pass = '') { Although this function could access $_POST['email'] and $_POST['pass'] directly, it’s better if the function is passed these values, making the function more independent.
  6. Should I use this method of showing images on a social media? Or is there a better way of showing user images on php?
  7. Awesome it works!!! I made a few adjustments of my own. on images.php: I redirected the uploads file into the htdocs file. Before: $dir = "/shou/uploads"; After: $dir = "/shou/htdocs/uploads"; I also redirected the img tag: Before: <img src=\"$image_name\" width=\"120\" height=\"120\"></a></li>\n"; After: <img src=\"uploads/$image_name\" width=\"120\" height=\"120\"></a></li>\n"; On show_images.php Then I changed the image path for this variable: Before: $image = "/shou/uploads/{$_GET['image']}"; After: $image = "/shou/htdocs/uploads/{$_GET['image']}"; Thank you, HartleySan and Margaux for your guys help and being very patient.
  8. Yes, from margaux's recommendation I fixed the problem. It's working fine and I'm getting the same results as the book. As for the results of your code, I have a blank page. I looked on my debugger and this is what it has stated: PHP Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in home/shou/htdocs/images.php on line 36 I tried other ways to work with you code like: echo "<li><a href =\"javascript: create_window('$image_name', $image_size[0], $image_size[1])\"><img src=\"$image_name\" width=\"120\" height=\"120\" alt=\"$image\" /></a></li>\n"; But that didn't work either.
  9. Yes, thank you with your explanation. I understand a little bit more. Unfortunately, your After: code did not work. I don't know if I'm correct, but shouldn't an img tag have an alt? And i do believe at the end of the img tag there should be a forward slash. Still, after those probable corrections, the clickable images has not shown.
  10. I'm sorry, I'm really new to programming. What do you mean by standard link to the src? Do you mean the actual image files? Since i'm using a foreach function to display multiple images, i can't specifically assign a image file to src.
  11. HartleySan: Sorry to offended you. I'll watch what I'll say next time and I really do appreciate your help. This is what I did so far in my images.php echo "<li><a href =\"javascript: create_window('$image_name', $image_size[0], $image_size[1])\" /> <img src=\"javascript: create_window('$image_name', $image_size[0], $image_size[1])\" /></a></li>\n"; What I'm trying to accomplish is to have all the uploaded pictures diplayed as a clickable image. Once clicked then the javascript popup image window is diplayed. The list of images doesn't really look so good. I'm not up to jQuery yet. I'm learning by chapter by chapter.
  12. No, I think there has to be a link element in order to be clickable. In between <a href="blah, blah..." > and </a>. I did put img tag but I don't know what to put in for src. Any suggestions?
  13. Thank you very much! Just one question, how do I display the images instead of displaying the links in the images.php script?
×
×
  • Create New...