Jump to content

aznkidzx

Members
  • Posts

    56
  • Joined

  • Last visited

    Never

Posts posted by aznkidzx

  1. Hello! I am coding an image hosting template and is having some difficulty. I have done the logo and the links. I tried to do the wrapper, but it wouldn't show up. In my style.css there is already a #wrapper with an image of img/wrapper.png. It just wouldn't show. Here's wrapper.png

    wrapper.png

     

    So far, it won't show in my html page. This is what i got so far..

     

    http://imghack.aznkidzx.co.cc/

  2. Help? I have this image upload script. I store all the images in /images and I have this image randomization from one directory. It works perfectly fine, but I want to add to it. Is it possible for it to say "<a href="#">Get It</a>" next to the image? Thanks for helping.

     

    <?php   
    /** * @desc PHP Code for showing random images from a directory */   
    
    //Assume That Images folder is placed in current directory and contain all of   
    //the picture files
    $dir="images";
    $files = scandir($dir);
    unset($files[0]);
    unset($files[1]);
    $rnd=rand(2,count($files));
    echo "<img src='$dir/".$files[$rnd]."'>";
    ?>

  3. Hello! I have this image script. I am just wondering if I could allow them to add more images to upload. I tried it but I had some difficulties and it only uploaded the first image browsed. I want it so like if someone finished browsing an image, BEFORE they upload, they have another option like Upload Another Image that makes another form field appear. Can somebody help me?

     

    Heres the script

    <?php
    //define a maxim size for the uploaded images in Kb
    define ("MAX_SIZE","2048"); 
    
    //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 and will not  upload the file,  
       //otherwise we will do more tests
    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
           {
          //print error message
              echo '<h1>Unsupported file 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*2048)
    {
       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;
    }}}}
    
    //If no errors registred, print the success message
    if(isset($_POST['Submit']) && !$errors) 
    {
        echo "<h1>File Uploaded Successfully!</h1>";
            echo "You can find your file <a href='" . $newname . "'>here</a>";
    }
    
    ?>
    
    <!--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="">
    <table>
        <tr><td><input type="file" name="image"></td></tr>
    
        <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr>
    </table>   
    </form>
    </div>

  4. I mean like when you browse for an image and finish browsing, on the same page, there'd be a link BEFORE pressing upload there'd be an option like Upload another image. Once you click the option, another browsing field would show up. I guess it is js. I am not sure.

  5. Hello! I have this image script. I am just wondering if I could allow them to add more images to upload. I tried it but I had some difficulties and it only uploaded the first image browsed.

     

    Heres the script

    <?php
    //define a maxim size for the uploaded images in Kb
    define ("MAX_SIZE","2048"); 
    
    //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 and will not  upload the file,  
       //otherwise we will do more tests
    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
           {
          //print error message
              echo '<h1>Unsupported file 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*2048)
    {
       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;
    }}}}
    
    //If no errors registred, print the success message
    if(isset($_POST['Submit']) && !$errors) 
    {
        echo "<h1>File Uploaded Successfully!</h1>";
            echo "You can find your file <a href='" . $newname . "'>here</a>";
    }
    
    ?>
    
    <!--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="">
    <table>
        <tr><td><input type="file" name="image"></td></tr>
    
        <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr>
    </table>   
    </form>
    </div>

  6. <?php
    //define a maxim size for the uploaded images in Kb
    define ("MAX_SIZE","2048"); 
    
    //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 and will not  upload the file,  
    //otherwise we will do more tests
    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
    		{
    	//print error message
    			echo '<h1>Unknown file extension! We only upload .gif .jpg .jpeg and .png!</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*2048)
    {
    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;
    }}}}
    
    //If no errors registred, print the success message
    if(isset($_POST['Submit']) && !$errors) 
    {
    	echo "<h1>File Uploaded Successfully!</h1>";
    }
    
    ?>
    
    <!--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="">
    <table>
    	<tr><td><input type="file" name="image"></td></tr>
    	<tr><td><input name="Submit" type="submit" value="Upload image"></td></tr>
    </table>	
    </form>

     

    Demo : http://test.colorev.co.cc/upload.php

  7. So sorry for double posting.. Modify button is hiding!! Also thanks for help! It works now! ;]

     

    But how do I make it so, when it says "Successful" it shows the link to the image and the image itself?

     

    --------------------

    Would $_POST['image'] work?

  8. Warning: copy(images/1233614813.jpg) [function.copy]: failed to open stream: Permission denied in upload.php on line 58

     

    Why does this happen? I am using this script for uploading images using file extensions jpg jpeg and png. How do I fix this problem?

     

     

    --------------------------------------------

    I followed a tutorial for the script.. The demo worked fine..

  9. You should consider this, but I found a rather easy captcha image verification code that is really easy to use.

     

    //new file called captcha.php

    <?php 
    session_start(); 
    $text = rand(10000,99999); 
    $_SESSION["vercode"] = $text; 
    $height = 25; 
    $width = 65; 
    
    $image_p = imagecreate($width, $height); 
    $black = imagecolorallocate($image_p, 0, 0, 0); 
    $white = imagecolorallocate($image_p, 255, 255, 255); 
    $font_size = 14; 
    
    imagestring($image_p, $font_size, 5, 5, $text, $white); 
    imagejpeg($image_p, null, 80); 
    ?>

     

    //form - already have your old form's contents

    <?php 
    session_start(); 
    if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  { 
         echo  '<strong>Incorrect verification code.</strong><br>'; 
    } else { 
       <form action="form.php" method="post">
          <label for="name">Name: </label><input type="text" name="name" id="name" /><br />
          <label for="email">Email: </label><input type="text" name="email" id="email" /><br />
          <label for="message">Message: </label><textarea rows="5" cols="30" name="message" id="message"></textarea><br />
          <input type="submit" name="submit" value="Submit" />
       </form>
         echo  '<strong>Verification successful.</strong><br>'; 
    }; 
    ?>
    

×
×
  • 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.