Jump to content
xisto Community

caronthegerman

Members
  • Content Count

    25
  • Joined

  • Last visited

Posts posted by caronthegerman


  1. Also the reason why the image isn't showing up is because of that extra slash at the beginning. If you change the slash to ./ then it should work fine (globally understood by all browsers).
    For example <img src="./'.$randir[$getrandir].''.$imgarray[$rand].'"


    Yea that worked. Thanks.
    I also changed the form action. However, the url is still http://forums.xisto.com/no_longer_exists/
    The question mark after randomizer.php is still showing up. Although it doesn't bother me, I don't get why it does.

    Also, could I change the line:
    return '<img src="./'.$randir[$getrandir].''.$imgarray[$rand].'" width="600" align="top">';
    so that if I click it, it also opens randomizer.php?

    For example, could I <a href a php returned image as well?

    I attached the randomizer.php file to this post.


    Oh and 8ennet, I started the php tutorial and am reading it daily.

  2. Hey it's me again. For some reason the pictures that come up on my randomizer.php are sometimes forced under where the picture is supposed to be. For example, if it is supposed to be in the middle of the screen, the top of the picture will be right where the bottom of the picture is supposed to be. When this happens the picture is under the "New Picture" button and you can only see a tiny bit of the top.


    Do you know what the problem is?

    It happens very randomly, but, because the images are random too, it might be because of the picture.


  3. It's looking good, as long as it works lol
    So next what are you going to do with the rest of the data the user has submitted? It uploads the image file ok, but the user fills out the rest of the form yet you don't store any of that data. You give them the option to credit them, don't credit them, and for some reason credit them on the forum which you don't seem to have yet.

    Are you going to be putting this information in to a database? Or even just storing it in a text file?



    Well since I didn't know how to do any of that stuff I just kind of wanted the information to be sent to my email so that in case anybody uploads something I know who uploaded it and if I can view the image and see if it is suitable and allowed.

    I didn't really think much about the credit thing, but I would probably post their name in the forum topic I make every day or so shows new pictures on a newpics#.html, which I post on the forum for anybody who wants to see the new pictures and not every picture.

    Here is an example: (the pictures don't work anymore because I put them in picturearchive/archive/, but since I don't have any users who care about new pictures yet, it doesn't matter that much. I'm putting up a new link and a new newpics5.html soon)

    4 new pictures added today.
    Check them out:
    http://forums.xisto.com/no_longer_exists/


    These will be left up for approximately 4 days.

    Taken from this forum topic.

  4. Yea you're right. I was getting kind of lazy and dependent on you guys. Heh.

    I put the two php files together and the html forms as well. It work as far as I know. I will post the two up.


    uploadimage.html

    <font color="black"><form enctype="multipart/form-data" action="uploadandmailform.php" method="post" name="form1" id="form1">  <table align="center" cellpadding="5" cellspacing="5" border="0" width="60%" bgcolor=#D2B48C>    <tr>      <td align="left" valign="top">        <p>Select A File<br>      </td> 	</tr> 	 	<tr>      <td align="left" valign="top">        <p><input type="hidden" name="MAX_FILE_SIZE" value="2000000">        <input name="uploaded_file" type="file">      </td>    </tr>     <tr>       <td align="left" valign="top">		       </td>    </tr>        <tr>      <td align="left" valign="top">		<span class="required">User Name:</span><br>		<input type="text" name="user_name" size="35" maxlength="50" />      </td>     </tr>          <tr>      <td align="left" valign="top">      	<span class="required">Real Name:</span><br>      	<input type="text" name="real_name" size="35" maxlength="50" />      </td>    </tr>        <tr>    	<td align="left" valign="top">    		<span class="required">Image Source:</span><br>    		<input type="text" name="image_source" size="35" maxlength="50" />    	</td>    </tr>        <tr>    	<td align="left" valign="top">    		<span class="required">Email:</span><br>    		<input type="text" name="email" size="35" maxlength="50" /><br><br>    	</td>    </tr>        <tr>    	<td align="left" valign="top">			<span class="notrequired">Tell us which one of the following you would like:</span> <br />				<input type="radio" name="category" onclick="updateTo('1');" />Please credit me for finding this picture.<br />				<input type="radio" name="category" onclick="updateTo('2');" />Please do not credit me for finding this picture.<br />				<input type="radio" name="category" onclick="updateTo('3');" />Please credit me for finding this picture only in the forums when the new pictures topic appears.<br /><br>				<input type="hidden" name="request_category" value=" " />		</td>	</tr>	<tr>		<td align="left" valign="top">			<input type="hidden" name="request_category" value=" " />			<span class="notrequired">Please give any additional information you think will be useful.</span><br />			<textarea name="request" rows="5" cols="38"></textarea><br><br>		</td>	</tr>		<tr>		<td align="left" valign="top">			 		</td>		<td align="left" valign="top">			 		</td>	</tr>		<tr>		<td align="left" valign="top">			<input type="submit" name="Submit" value="Submit" />		</td>	</tr>	</p>  </table></form></font>


    uploadandmailform.php
         ($_FILES['uploaded_file']['type'] == 'image/png')    ||
    ($_FILES['uploaded_file']['type'] == 'image/jpeg') ||
    ($_FILES['uploaded_file']['type'] == 'image/jpg') ||
    ($_FILES['uploaded_file']['type'] == 'image/pjpeg')) &&
    ($_FILES['uploaded_file']['size'] < 2000000)) {



    if ($_FILES['uploaded_file']['error'] > 0) {
    echo "Error linenums:0'><?php if ((($_FILES['uploaded_file']['type'] == 'image/gif') || ($_FILES['uploaded_file']['type'] == 'image/png') || ($_FILES['uploaded_file']['type'] == 'image/jpeg') || ($_FILES['uploaded_file']['type'] == 'image/jpg') || ($_FILES['uploaded_file']['type'] == 'image/pjpeg')) && ($_FILES['uploaded_file']['size'] < 2000000)) {if ($_FILES['uploaded_file']['error'] > 0) { echo "Error: " . $_FILES['uploaded_file']['error'] . "<br>";} else { echo "Upload: " . $_FILES['uploaded_file']['name'] . "<br>"; echo "Type: " . $_FILES['uploaded_file']['type'] . "<br>"; echo "Size: " . ($_FILES['uploaded_file']['size'] / 1024) . " kB<br>"; echo "Stored in: " . $_FILES['uploaded_file']['tmp_name'] . "<br><br>"; $target_path = "useruploads/"; $target_thumb_path = "useruploadstrue/"; if(!is_writable($target_path)) { die('Cannot be uploaded to the specified directory. Please change permission to 777.'); } if(!is_writable($target_thumb_path)) { die('Thumbnail cannot be created. Please change permission to 777.'); } $uploaded_file = $_FILES['uploaded_file']['tmp_name']; $src = imagecreatefromjpeg($uploaded_file); list($width, $height)=getimagesize($uploaded_file); $new_width = 150; $new_height = ($height/$width)*$new_width; $tmp = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $filename = $target_thumb_path . $_FILES['uploaded_file']['name']; imagejpeg($tmp, $filename, 100); imagedestroy($src); imagedestroy($tmp); $target_path = $target_path . basename( $_FILES['uploaded_file']['name']); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) { echo "The file " . basename( $_FILES['uploaded_file']['name']) . " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; }} }$upload_name= $_POST['uploaded'];$user_name= $_POST['user_name']; $real_name= $_POST['real_name']; $image_source= $_POST['image_source']; $email= $_POST['email']; $category= $_POST['category']; $request_category= $_POST['request_category']; $request= $_POST['request']; $message= $_POST['message']; $body = " User Name: $user_name Real Name: $real_name Name of Image: " . basename( $_FILES['uploaded_file']['name']) . "Image Source: $image_source Email: $email Request Category: $request_category Additional Info: $request$message "; if (!isset($email) || !isset($user_name)) { header("Location: [url="http://forums.xisto.com/no_longer_exists/; "); } elseif (empty($email) || empty($user_name)) { header("Location: [url="http://forums.xisto.com/no_longer_exists/; "); } else { mail("admin_caron@loldmypants.com","From: loldmypants.com visitor",$body); header("Location: [url="http://forums.xisto.com/no_longer_exists/; "); } ?>
    Sorry that I made it long again. :)

  5. Hi guys,

    I have pieced together two fine pieces of code but need to put these two puzzle pieces together correctly.

    So, this is my upload script:

    <form enctype="multipart/form-data" action="upload.php" method="POST">  <table align="left" cellpadding="5" cellspacing="5" border="0" width="100%" bgcolor=#FFFFFF>    <tr>      <td align="left" valign="top">        Select A File      </td>       <td align="left" valign="top">        <input type="hidden" name="MAX_FILE_SIZE" value="2000000">        <input name="uploaded_file" type="file">      </td>    </tr>     <tr>      <td align="left" valign="top">               </td>       <td align="left" valign="top">        <input type="submit" value="Upload This File">      </td>    </tr>  </table></form>

    With upload.php being:
         ($_FILES['uploaded_file']['type'] == 'image/png')    ||
    ($_FILES['uploaded_file']['type'] == 'image/jpeg') ||
    ($_FILES['uploaded_file']['type'] == 'image/jpg') ||
    ($_FILES['uploaded_file']['type'] == 'image/pjpeg')) &&
    ($_FILES['uploaded_file']['size'] < 2000000)) {



    if ($_FILES['uploaded_file']['error'] > 0) {
    echo "Error linenums:0'><?phpif ((($_FILES['uploaded_file']['type'] == 'image/gif') || ($_FILES['uploaded_file']['type'] == 'image/png') || ($_FILES['uploaded_file']['type'] == 'image/jpeg') || ($_FILES['uploaded_file']['type'] == 'image/jpg') || ($_FILES['uploaded_file']['type'] == 'image/pjpeg')) && ($_FILES['uploaded_file']['size'] < 2000000)) {if ($_FILES['uploaded_file']['error'] > 0) { echo "Error: " . $_FILES['uploaded_file']['error'] . "<br>";} else { echo "Upload: " . $_FILES['uploaded_file']['name'] . "<br>"; echo "Type: " . $_FILES['uploaded_file']['type'] . "<br>"; echo "Size: " . ($_FILES['uploaded_file']['size'] / 1024) . " kB<br>"; echo "Stored in: " . $_FILES['uploaded_file']['tmp_name'] . "<br>"; $target_path = "useruploads/"; $target_thumb_path = "useruploadstrue/"; if(!is_writable($target_path)) { die('Cannot be uploaded to the specified directory. Please change permission to 777.'); } if(!is_writable($target_thumb_path)) { die('Thumbnail cannot be created. Please change permission to 777.'); } $uploaded_file = $_FILES['uploaded_file']['tmp_name']; $src = imagecreatefromjpeg($uploaded_file); list($width, $height)=getimagesize($uploaded_file); $new_width = 150; $new_height = ($height/$width)*$new_width; $tmp = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $filename = $target_thumb_path . $_FILES['uploaded_file']['name']; imagejpeg($tmp, $filename, 100); imagedestroy($src); imagedestroy($tmp); $target_path = $target_path . basename( $_FILES['uploaded_file']['name']); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) { echo "The file " . basename( $_FILES['uploaded_file']['name']) . " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; }} }?>



    The second piece of the puzzle is my email form. This is the html part:
    <form action="mailform.php" method="post" name="form1" id="form1"><table width="450" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td background="styles/images/gif/clearpixel.gif" class="text"><p><span class="required">User Name:</span><br><input type="text" name="user_name" size="35" maxlength="50" /><br><br><span class="required">Real Name:</span><br /><input type="text" name="real_name" size="35" maxlength="50" /><br><br><span class="required">Image Source:</span><br /><input type="text" name="image_source" size="35" maxlength="75" /><br><br><span class="required">Email:</span><br /><input type="text" name="email" size="35" maxlength="100" /><br><br><span class="notrequired">Tell us which one of the followingyou would like:</span> <br /><input type="radio" name="category" onclick="updateTo('1');" />Please credit me for finding this picture.<br /><input type="radio" name="category" onclick="updateTo('2');" />Please do not credit me for finding this picture.<br /><input type="radio" name="category" onclick="updateTo('3');" />Please credit me for finding this picture only in the forums when the new pictures topic appears.<br /><br><input type="hidden" name="request_category" value=" " /><span class="notrequired">Please give any additional informationyou think will be useful.</span><br /><textarea name="request" rows="5" cols="38"></textarea><br><br><input type="submit" name="Submit" value="Submit" /></p></td></tr></table></form>

    And this is my mailform.php:
    $user_name= $_POST['user_name']; 
    $real_name= $_POST['real_name'];
    $image_source= $_POST['image_source'];
    $email= $_POST['email'];
    $category= $_POST['category'];
    $request_category= $_POST['request_category'];
    $request= $_POST['request'];
    $message= $_POST['message'];

    $body = "
    User Name linenums:0'><?php $upload_name= $_POST['uploaded'];$user_name= $_POST['user_name']; $real_name= $_POST['real_name']; $image_source= $_POST['image_source']; $email= $_POST['email']; $category= $_POST['category']; $request_category= $_POST['request_category']; $request= $_POST['request']; $message= $_POST['message']; $body = " User Name: $user_name Real Name: $real_name Name of Image: $upload_nameImage Source: $image_source Email: $email Request Category: $request_category Additional Info: $request$message "; if (!isset($email) || !isset($user_name)) { header("Location: [url="http://forums.xisto.com/no_longer_exists/; "); } elseif (empty($email) || empty($user_name)) { header("Location: [url="http://forums.xisto.com/no_longer_exists/; "); } else { mail("admin_caron@loldmypants.com","From: loldmypants.com visitor",$body); header("Location: [url="http://forums.xisto.com/no_longer_exists/; "); } ?>

    What I would like to do is to put the two php files into one and the two forms into one. I would also like to have the name or full url of the uploaded image to be called by $upload_name and to be displayed in the $body of the email that will be sent.

    If you want to help, please do. Thanks :)

  6. It works!!! Thank you, thank you, thank you.Also, is there any way to make the width about 600 pixels and to calculate a new height to keep the aspect ratio the same?For example something like this:

        list($width, $height)=getimagesize($uploaded_file)    $new_width   = 600;    $new_height  = ($height/$width)*$new_width;    $tmp         = imagecreatetruecolor($new_width, $new_height);    imagecopyresampled($tmp, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height);


  7. I changed everything as you said, but now I'm getting this error:Warning: readdir(): supplied argument is not a valid Directory resource in /home/caronthegerman/loldmypants.com/picturearchive/randomizer.php on line 107Warning: closedir(): supplied argument is not a valid Directory resource in /home/caronthegerman/loldmypants.com/picturearchive/randomizer.php on line 113I uploaded randomizer.php as an attachment.


  8. Something rather annoying about this post being stretched out like this, but never mind lol
    Ok I'm going to write a function below for you so you can select a random image from a random folder each time the function is called.
    What I have done is basically taken the coding example from here (so the credit really goes to that person) and just added a bit of extra functionality
    too incorporate multiple folders.

    function getRandomImage(){// Change directories to your image directories, you can also add more if you wish eg. $randir[2] = 'images/randomdirectory3/'; just remember to add the trailing slash$randir[0] = 'images/randomdirectory1/';$randir[1] = 'images/randomdirectory2/';$getrandir = array_rand($randir, 1);$dir=opendir($randir[$getrandir[0]]);$i=0;while($imgfile = readdir($dir)){if (($imgfile != ".") && ($imgfile != "..")){$imgarray[$i] = $imgfile;$i++;}}closedir($dir);$rand=rand(0,count($imgarray)-1);if($rand >= 0){return '<img src="'.$randir[$getrandir[0]].''.$imgarray[$rand].'" width="170" height="137">';}}

    So now all you have to do is change the following lines:

    $randir[0] = 'images/randomdirectory1/';
    $randir[1] = 'images/randomdirectory2/';

    to the directorys you want to pull a random image from and like I stated in the comments, you can add more directories if you wish.
    So now you have changed your directories all you need to do is echo the function and it will display your image.

    echo getRandomImage();

    I haven't tested the modified code but looking over it there shouldn't be a problem, let me know if it works.

    I made a new topic since this really was getting annoying.
    Here's the new topic.

  9. Something rather annoying about this post being stretched out like this, but never mind lol

     

    Ok I'm going to write a function below for you so you can select a random image from a random folder each time the function is called.

    What I have done is basically taken the coding example from here (so the credit really goes to that person) and just added a bit of extra functionality

    too incorporate multiple folders.

     

    
    

    $randir[0] = 'http linenums:0'><?phpfunction getRandomImage(){// Change directories to your image directories, you can also add more if you wish eg. $randir[2] = 'images/randomdirectory3/'; just remember to add the trailing slash$randir[0] = 'http://forums.xisto.com/no_longer_exists/; = 'http://forums.xisto.com/no_longer_exists/ = array_rand($randir, 1);$dir=opendir($randir[$getrandir[0]]);$i=0;while($imgfile = readdir($dir)){if (($imgfile != ".") && ($imgfile != "..")){$imgarray[$i] = $imgfile;$i++;}}closedir($dir);$rand=rand(0,count($imgarray)-1);if($rand >= 0){return '<img src="'.$randir[$getrandir[0]].''.$imgarray[$rand].'" width="170" height="137">';}}echo getRandomImage();?>


    But this gives me an error:

    Warning: readdir(): supplied argument is not a valid Directory resource in /home/caronthegerman/loldmypants.com/picturearchive/randomizer.php on line 12

     

    Warning: closedir(): supplied argument is not a valid Directory resource in /home/caronthegerman/loldmypants.com/picturearchive/randomizer.php on line 18

     

     

    There is a broken image box under this error message.

     

    I have no idea what to do. Even the single folder random picture does not work anymore. :-X

     

     

    Also, would I be able to

    <a href=""><img src="http://forums.xisto.com/no_longer_exists/;
    this randomizer?

  10. Awesome, it worked! Thanks.The only problem now is that the thumbnail part isn't working. But that's not important. Instead, do you know how I could make an image rotator that rotates using multiple folders?For example, it takes a random picture from 2 folders and shows it on the page and upon refresh a new picture is seen?I found a few that do it with one folder, but I could not find one with 2 folders.


  11. Hey guys,

     

    I'm having some trouble setting up a file uploader on my site. I used this website to make the uploader and did everything as I was told, as far as I know. I double checked my code and have no idea what I'm doing wrong.

     

    When I try to upload a file I get an error message:

    Parse error: syntax error, unexpected T_VARIABLE in /home/caronthegerman/loldmypants.com/pictures/uploader/upload.php on line 73

     

    Here is uploadimage.html: (View it here.)

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://forums.xisto.com/no_longer_exists/;'>http://forums.xisto.com/no_longer_exists/;    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">  <meta name="google-site-verification" content="-XdND18efjz9LUFurJmW397G7-15WzTHnGlaxk8uGbw">  <title>Submit a Picture</title>      <meta content="Andrew Roberson, Blackwell Stith, Caron Schaller" name="author">    <meta content="Where Memes Go to Die" name="description"> </head><body style="background-image: url(http://http://www.goowik.com/wp-content/uploads/2008/11/background.jpg);"><div style="text-align: center;"><script type="text/javascript"><!--google_ad_client = "pub-6677878668571681";/* Homepage Banner created Sat, Aug 7th 2010 */google_ad_slot = "0838308373";google_ad_width = 468;google_ad_height = 60;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><script type="text/javascript"><!--google_ad_client = "pub-6677878668571681";/* Homepage Banner created Sat, Aug 7th 2010 */google_ad_slot = "2337475403";google_ad_width = 468;google_ad_height = 60;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><br><br><a href="http://forums.xisto.com/no_longer_exists/;'>http://forums.xisto.com/no_longer_exists/; <a href="http://forums.xisto.com/no_longer_exists/;'>http://forums.xisto.com/no_longer_exists/; <a href="http://forums.xisto.com/no_longer_exists/ href="/advertisestats.html">Advertise with us</a><big><br style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;"></big><big><div style="text-align: center;"><big><big><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">L</span><big><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">L</span><big><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">L</span><big><span style="color: rgb(51, 102, 255); font-weight: bold; font-family: Desdemona;">LOLD</span><small><span style="color: rgb(51, 102, 255); font-weight: bold; font-family: Desdemona;">D</span><small><span style="color: rgb(51, 102, 255); font-weight: bold; font-family: Desdemona;">D</span><small><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">D        M</span><big><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">M</span><big><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">M</span><big><span style="color: rgb(51, 102, 255); font-weight: bold; font-family: Desdemona;">MY</span><small><span style="color: rgb(51, 102, 255); font-weight: bold; font-family: Desdemona;">Y</span><small><span style="color: rgb(51, 102, 255); font-weight: bold; font-family: Desdemona;">Y</span><small><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">Y      P</span><big><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">P</span><big><span style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">P</span><big><span style="color: rgb(51, 102, 255); font-weight: bold; font-family: Desdemona;">PANTS</span><small style="font-family: Desdemona; color: rgb(51, 102, 255); font-weight: bold;">S<small>S<small><small>S</small></small></small></small><br></big><small style="color: white;"><small><span style="font-style: italic;">WhereMemes go to die.<br></span></small></small></big></big></big></small></small></small></big></big></big></small></small></small></big></big></big></big></big><small><small><br><br><br><font color="white"><div style="text-align: left"><big><big><b><u>Submitting a Picture: Part 2</u></b><br><br><!-- The data encoding type, enctype, MUST be specified as below --><form enctype="multipart/form-data" action="uploader/upload.php" method="POST">  <table align="left" cellpadding="5" cellspacing="5" border="0" width="100%" bgcolor=#FFFFFF>    <tr>      <td align="left" valign="top">        Select A File      </td>       <td align="left" valign="top">        <!-- MAX_FILE_SIZE (measured in bytes) must precede the file input field and its value         is the maximum filesize accepted by PHP. Fooling this setting on the browser side is         quite easy, so never rely on files with a greater size being blocked by this feature.         The PHP settings for maximum-size, however, cannot be fooled. This form element         should always be used as it saves users the trouble of waiting for a big file being         transferred only to find that it was too big and the transfer failed. -->        <input type="hidden" name="MAX_FILE_SIZE" value="2000000">         <!-- Name of input element determines name in $_FILES array.        uploaded_file is the reference assigned in the form. This will be needed to         tell the $_FILES array which file should be handled -->        <input name="uploaded_file" type="file">      </td>    </tr>     <tr>      <td align="left" valign="top">               </td>       <td align="left" valign="top">        <input type="submit" value="Upload This File">      </td>    </tr>  </table></form><br><br><br><br></font><br><br></font></body></html>

     

     

    Here is upload.php: (View it here.)

    
    

    ($_FILES['uploaded_file']['type'] == 'image/png') ||

    ($_FILES['uploaded_file']['type'] == 'image/jpeg') ||

    ($_FILES['uploaded_file']['type'] == 'image/jpg') ||

    ($_FILES['uploaded_file']['type'] == 'image/pjpeg')) &&

    ($_FILES['uploaded_file']['size'] < 2000000)) {

     

     

     

    if ($_FILES['uploaded_file']['error'] > 0) {

    # The error code associated with this file upload.

    echo "Error linenums:0'><?phpif ((($_FILES['uploaded_file']['type'] == 'image/gif') || ($_FILES['uploaded_file']['type'] == 'image/png') || ($_FILES['uploaded_file']['type'] == 'image/jpeg') || ($_FILES['uploaded_file']['type'] == 'image/jpg') || ($_FILES['uploaded_file']['type'] == 'image/pjpeg')) && ($_FILES['uploaded_file']['size'] < 2000000)) {if ($_FILES['uploaded_file']['error'] > 0) { # The error code associated with this file upload. echo "Error: " . $_FILES['uploaded_file']['error'] . "<br>";} else { # The original name of the file on the client machine. echo "Upload: " . $_FILES['uploaded_file']['name'] . "<br>"; # The mime type of the file, if the browser provided this information. # This mime type is however not checked on the PHP side and therefore it's value should # should not be taken for granted. echo "Type: " . $_FILES['uploaded_file']['type'] . "<br>"; # The size, in bytes, of the uploaded file. echo "Size: " . ($_FILES['uploaded_file']['size'] / 1024) . " kB<br>"; # The temporary filename of the file in which the uploaded file was stored on the server. echo "Stored in: " . $_FILES['uploaded_file']['tmp_name'] . "<br>"; # Where the file is going to be placed and thumbnail will be creatd; choose this judiciously # These locations needs to have 'write' permissions for 'apache' (or the web-user) $target_path = "useruploadstrue/"; $target_thumb_path = "useruploads/"; if(!is_writable($target_path)) { die('Cannot be uploaded to the specified directory. Please change permission to 777.'); } if(!is_writable($target_thumb_path)) { die('Thumbnail cannot be created. Please change permission to 777.'); } # This is the temporary file created by PHP. $uploaded_file = $_FILES['uploaded_file']['tmp_name']; # Create an image from the $uploaded_file so that it can be thumbnailed $src = imagecreatefromjpeg($uploaded_file); # Extract the original size of the uploaded image list($width, $height)=getimagesize($uploaded_file); # Let the thumbnail be 150 pixels in width, height adjusted based on original aspect ratio $new_height = 584; $new_width = ($width/$height)*$new_height; $tmp = imagecreatetruecolor($new_height, $new_width); # The following line does the thumbnailing imagecopyresampled($tmp, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height); # Write the thumbnailed image to disk # Check/modify this part for other image types $filename = $target_thumb_path . $_FILES['uploaded_file']['name']; imagejpeg($tmp, $filename, 100); # PHP will clean up the temporary files after the request is completed imagedestroy($src); imagedestroy($tmp) $target_path = $target_path . basename( $_FILES['uploaded_file']['name']); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) { echo "The file " . basename( $_FILES['uploaded_file']['name']) . " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; }}?>

     

    Thanks for any helpful comments.


  12. Great!
    Tell me when you've learned how to make your own tables and insert new rows with PHPMyAdmin!




    Well i've been trying and trying to install phpmyadmin on my snow leopard, but I can't find out what my username and password is. Apparently my username is root (installation guide) but I have no idea how to get my password. I searched the internet countless times, tried my ftp password, tried every password I could think of, but it still didn't work. I don't know what to do. D:

  13. Sorry for double posting, seems like I can't edit my post ten minutes after posting..
    Anyways, using mod_rewrite, you can use PHP to choose a picture using $_GET, and then make the extension look like .jpg.html or whatever you want it to look like instead of ?picture=blabla.jpg
    Is that what you are looking for?

    Regards
    /Feelay | Nanashi



    Does this make the url be savable? Like if I change the url of a certain picture on the page that randomly selects one and a user saves that url and opens it the next day, will it show the same picture it did when he first saw it?

  14. Hey guys,I've been trying to make a random image rotator that changes the url specifically so that the visitor can save the picture as a favorite or bookmark. All those I have tried will only show a random picture but the url continually remains at or others. I know I could make a php script that chooses randomly from many urls but that would mean I have to create an html file for every single one of my 150+ pictures that I want to rotate throughThanks for any help,Caron

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.