Jump to content

zeusthegreat

Member
  • Posts

    86
  • Joined

  • Last visited

Everything posted by zeusthegreat

  1. $ret_val or $retval which of these is true and what does it mean implementing the linux route command in php --- $ret_val, i am sorry guys i have to understand what i am doing and what it means or it is though i am half ar$ed and i have never been that.... <?PHP // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function getImages($dir) { global $imagetypes; // array to hold return value below is $retval $retval = array(); // add trailing slash if missing if(substr($dir, -1) != "/") $dir .= "/"; // full server path to directory $fulldir = "{$_SERVER['DOCUMENT_ROOT']}/$dir"; // what does $d mean //@dir ? //$entry $d = @dir($fulldir) or die("getImages: Failed opening directory $dir for reading"); while(false !== ($entry = $d->read())) { // skip hidden files if($entry[0] == ".") continue; // check for image files if(in_array(mime_content_type("$fulldir$entry"), $imagetypes)) { $retval[] = array( "file" => "/$dir$entry", "size" => getimagesize("$fulldir$entry") ); } } $d->close(); return $retval; } ?>
  2. thanks ben how do you say i wanted to show all the images in the images folder at one time on one page say i have 30 images in my images folder and i want them all to show at the same time and when a new image uploaded that is just added to the already 30 images on that page. hope this is clear
  3. ben this file uploads to the server in a folder but not to the page!!!! so i am close
  4. form_upload.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">'>http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> body,td,th { font-size: 14px; color: #000; font-weight: bold; } body { background-color: #0F0; } </style> </head> <body> <!--next comes the form, you must set the enctype to "multipart/frm-data" and use an input type "file" --> <form name="newad" method="post" enctype="multipart/form-data" action="upload_image.php"> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> </body> </html> upload_image.php <!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> <style type="text/css"> body,td,th { font-size: 14px; color: #000; font-weight: bold; } body { background-color: #0F0; } img { background-repeat: no-repeat; background-position: center center; width: 100px; height: 100px; } img { background-repeat: no-repeat; padding-left: 5px; } </style> </head> // i have been trying to do what ben told me in my post **uploaded image to show on page** and want to know if i am on the right track <body> <p><img src="images/1301661356.jpg" width="1680" height="1050" alt="IMAGE" /><img src="images/1301933656.jpg" width="200" height="200" alt="IMAGE1" /><img src="images/1301581797.jpg" width="1000" height="355" alt="IMAGE2" /><img src="images/1301582412.jpg" width="225" height="338" alt="IMAGE3" /><img src="images/1301586295.jpg" width="200" height="200" alt="IMAGE4" /><img src="images/1301661667.jpg" width="200" height="200" alt="IMAGE5" /><img src="images/1301662173.jpg" width="960" height="960" alt="IMAGE6" /><img src="images/1301662216.gif" width="90" height="90" alt="IMAGE7" /><img src="images/1301662498.jpg" width="200" height="200" alt="IMAGE8" /><img src="images/1301931822.jpg" width="1600" height="1200" alt="IMAGE9" /><img src="images/drupaln.jpg" width="349" height="400" alt="IMAGE10" /><img src="images/5b8c7cf37396b0a35807919bed5788c0.gif" width="160" height="600" alt="IMAGE11" /><img src="images/1974.jpg" width="300" height="481" alt="IMAGE12" /><img src="images/18861.jpg" width="60" height="60" alt="IMAGE13" /><img src="images/486340_vb.jpg" width="200" height="200" alt="IMAGE14" /></p> <p><img src="images/486346_vb.jpg" width="200" height="200" alt="IMAGE15" /> <img src="images/487214_vb.jpg" width="200" height="200" alt="IMAGE16" /><img src="images/487459_vb.jpg" width="200" height="200" alt="IMAGE17" /></p> <div> <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","20000000"); //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; } //the above strrpos what does this mean //and the exclamation //strlen - what does this mean //$1 and $i -- what do these mean //substr -- what does this mean // i gather return just returns the extension //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-- ****** isset -- what does this mean 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 **** strtolower what does this mean $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 and will not upload the file, otherwize we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $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=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*20000000) { echo '<h1>You have exceeded the size limit!</h1>'; $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="images/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} { // custom area below PRINT "$image <h1>File Uploaded Successfully! Try again!</h1>"; } ?> </div> </body> </html>
  5. THIS IS PICTURE_PAGE.PHP <style type="text/css"> body { background-color: #FF0; } </style> <div> <?php echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["images_upload"]; // LINE 11 ?> </div>
  6. html> <body> <form action="Picture_page.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> called form_new.php <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["images_uploads"]; } } else { echo "Invalid file"; } ?> called upload_file.php <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 200000000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["images_uploads"]; } } else { echo "Invalid file"; } ?> called restriction_upload.php <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 2000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["picture_page_name"] . "<br />"; if (file_exists("upload" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["picture_page_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload_buttom/images_uploads" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> called saving_upload.php this is what i get back from browser Upload: 1a81df52844236.gif Type: image/gif Size: 8.619140625 Kb Notice: Undefined index: images_upload in C:\wamp\www\upload_button\Picture_page.php on line 11 Stored in: now i have customized the stored in to a folder called image_uploads thought i was doing write but not sure now and i can only get the details of upload and not the picy, i have actually got it with a broken image before but forgot how i got there!!!! basically i want picys and word docs to be uploaded by public and for the pictures to go to a certain folder and then show on a specific page, password protected would be nice also. thanks anybody for any help!!!!
  7. it was my naming convention thankyou ben if you ever need any help making mistakes you know who to contact eh ben!!!
  8. broken image when include used could you give your opinion

    as i am sure it is just the path but tryed lots of different variations even putting the files into the pear file and no joy..

    please help

    and thankyou ben

    talos

  9. have linked the image back dirctly to its source and even put a copy of the folder in pear and no joy, instead of a broken image it shows a holding image with a little image picy in top left.... why do the easy things torment me!!! i am just going to run head first into a wall to see if it helps any ha!
  10. broms_page.php !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">'>http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <h3>Brom's Page</h3> <img src="images/Urban Blank Billboards/Stock Vector - Urban Blank Billboards/Urban_ Blank_ Billboards1.jpg" /> <?php @include("banner.php"); print "<br><br>"; ?> </body> </html> banner_inc.php <img src="bromssite/images/Urban Blank Billboards/Stock Vector - Urban Blank Billboards/Urban_ Blank_ Billboards1.jpgweb"> <?php $zeus_password = "great"; ?> </p> <p> </p> when viewed it is broken image probably really easy or just overlooked put any help would be good source code <!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> <h3>Brom's Page</h3> <img src="images/Urban Blank Billboards/Stock Vector - Urban Blank Billboards/Urban_ Blank_ Billboards1.jpg" /> <br><br> </body> </html> thanks in advance!
  11. lets say you have a html form an you have uploaded an image using this form to a particular page called upload.php could you then use the include statement to place all your uploaded images to your current page without any complications, or is this not a good thing to do? thankyou!
  12. function footer($argument, $arg = "Brom is god!") { echo "$argument<br><br>"; if($arg == "Brom is god!") { return "hey, I know " .$arg; } else { return "Do I know you " .$arg ."?"; } ?> <?php echo footer("stefan"); ?> </body> </html> have followed this lesson twice and i am suffering from mind block just cannot see where i am wrong as the errror this shows is Parse error: syntax error, unexpected $end in C:\wamp\www\php_beginners\conditional_statements\function_custom_default_next.php on line 63 thankyou
  13. $did_send = mail('killerphp.com','killerphp.com Test Email', "The body message."); echo "Email sent: " . $did_send; i saved this viewed it in my browser and got back Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\php_beginners\conditional_statements\email_function.php on line 22 Email sent: does this mean that i have not set something up for the email to work...
  14. function upload($file_id, $folder="", $types="") { if(!$_FILES[$file_id]['name']) return array('','No file specified'); $file_title = $_FILES[$file_id]['name']; //Get file extension $ext_arr = split("\.",basename($file_title)); $ext = strtolower($ext_arr[count($ext_arr)-1]); //Get the last extension //Not really uniqe - but for all practical reasons, it is $uniqer = substr(md5(uniqid(rand(),1)),0,5); $file_name = $uniqer . '_' . $file_title;//Get Unique Name $all_types = explode(",",strtolower($types)); if($types) { if(in_array($ext,$all_types)); else { $result = "'".$_FILES[$file_id]['name']."' is not a valid file."; //Show error if any. return array('',$result); } } WHAT I MEAN IS if(!$_FILES[$file_id]['name']) return array('','No file specified'); WHAT DOES THE EXCLAMATION MARK MEAN BEFORE $_FILES HAVE GOOGLED AND I GET DIFFERENT ANSWERS, SO THOUGHT I WOULD ASK SOMEBODY WHO WOULD KNOW FOR CERTAIN
  15. so if i wanted to place an image on in a certain part of a page i would just either use pixels to determine this or place inside a div, then how would i get the next image to show underneath or to the side pixels again or is there some other command is what i am asking? thanks for the look i am trying to understand ecerything that i am doing and then i always learn well!
  16. hello i am racking my tiny brain to once i have uploaded an image to a particular page to get the image to appear on the page that it has been uploaded to . am i best to upload the image and can i then use include to make the image show on the page or do i have to create a div or a html table and upload the image in there is there a particular function that i am missing or do i have to create an image variable and then go from there all the training on this subject are really intimerdating i just want a bit of help.... do i upload to the page and what do i use i guess it is not echo possibly print_r($_FILES); headache headache thanks for any help
  17. print '<IMG SRC="$php_photo2_file" WIDTH="268" HEIGHT="176" BORDER="0" ALT="">'; is the above the answer thankyou everyone what i really want is for my image to display and for nobody to be able to click on it and download it!!!
  18. thanks ben i shall try it monday
  19. head> <meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-1"> <title></Title> </head> <body> <?php include("class.php"); ?> <?php include("classdog.php"); ?> <?php $my_snake = new snake(); $my_snake->eat_bugs(); $dog = new dog(); $dog->eat_snake(); ?> </body> </html> index.php <?php //How . or if, do i use a function from an class while in an other class. class snake { function eat_bugs() { echo "He eats bugs."; } } ?> class.php <?php class dog { function eat_snake() { echo "The dog ate the snake!"; } } ?> classdog.php cannot get the second message to show no error it just is not showing (the dog ate the snake) being the message.... must be something simple please help and thankyou for any help
  20. what i want to do basically is to use an upload button to upload pictures and word docs to a specific page on my site lets say picture_page.php <html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> this file is called form_new.php do i need to customize the upload_file.php to lets the picture_page.php <?php if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } ?> and then the next page is called say --- upload_file.php do i have to customize on this page tmp_name to picture_page_name <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> lets say this page is called Saving_upload.php do i have to alter echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; to echo "Picture_page file: " . $_FILES["file"]["Picture_Page_name"] . "<br />"; and move_uploaded_file($_FILES["file"]["tmp_name"], to move_uploaded_file($_FILES["file"]["picture_page_name"], <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } } else { echo "Invalid file"; } ?> this page is called restriction_upload.php do i have to alter the below to echo "Stored in: " . $_FILES["file"]["tmp_name"]; echo "Stored in: " . $_FILES["file"]["picture_page_name"]; am i on the right track how do i then get the picture_page.php to show the docs or picys guidance would be great!!!
  21. i get this message i get this message while testing in a browser on exercise 7 lesson 11 sessions part 3 is there something wrong with my browser because in my previous lesson i could not view my page directly through dreamweaver but i could by putiing in the url strange but as i see it the more mistakes i make the more i learn!!!! great eh!!! Notice: Undefined index: browser in C:\wamp\www\sessions\session.php on line 21
  22. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4loose.dtd"> <html> <head> <meta http-equiv="Content-Type" Content="text/html; charset=iso-8859-1"> <title></Title> <?php function footer($email, $arg = "Jimmy!") { echo "$email<br><br>"; if($arg == "Jimmy!") { return "hey, I know " .$arg; } else { return "Do I Know You" .$arg ."?"; } ?> </head> <body> <?php echo footer("er" ); ?> </body> </html> 2mims 15 secs on following this lesson i get the following when trying to view in browser have gone through the code and can not see any errors browser error Parse error: syntax error, unexpected $end in C:\wamp\www\functions_custom_three.php on line 56 advise please
  23. zeusthegreat

    upload button

    i am trying to learn how to do an upload button so that people can upload pictures to my site and want to use php to upload
×
×
  • Create New...