"UPLOAD a photo to my sever" script?

Discussion in 'Scripts' started by on9now.com, May 5, 2006.

  1. #1
    Can anyone tell me where i can find a script that allows user to upload pictures to my site? I don't need alot of fancy features, just upload and they will have the url link of the pictures.. and i can set the size limit.

    Anyone?
     
    on9now.com, May 5, 2006 IP
  2. Shost

    Shost Peon

    Messages:
    5
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    // IMAGE SIZE
    $_IMAGESSIZE="60000";
    // YOUR IMAGE DIRECTORY
    $_imagesdir="images/"; // remeber chmod 777 in this dir
    if(isset($_POST['addfiles']))
    {
    
         $types = array("image/pjpeg","image/jpeg","image/gif","image/x-png","image/png","image/bmp");
        // $uploadfile =  $_FILES['fmage']['name'];
    	 $uploadfile =  md5(time()).$_FILES['fmage']['name'];
        if ($_FILES['fmage']['size']>$_IMAGESSIZE)
    	   { 
    	 $error.="Image is too big";
    	   }
         if (!in_array($_FILES['fmage']['type'], $types)){ 
         $error.="only images please"; 
         $name =  $_FILES['fmage']['name']; 
         $type =  $_FILES['fmage']['type']; 
         $size =  $_FILES['fmage']['size']; 
         $tmp =   $_FILES['fmage']['name']; 
    $error.="i send ".$type." this files no are allowed to upload";
           } 
        if (empty($error))
           {
     move_uploaded_file($_FILES['fmage']['tmp_name'],"".$_imagesdir."/$uploadfile");
    	 $_OK="File uploaded :)";
           }
    
    }
    
    
        echo $error."".$_OK;
    	?>
    	<form method="POST" enctype="multipart/form-data" >
    <input type=file name="fmage">
    <input type=submit name="addfiles" value="Send image" >
        
         </form>
    PHP:
    Best regards
     
    Shost, May 5, 2006 IP
  3. wvccboy

    wvccboy Notable Member

    Messages:
    2,632
    Likes Received:
    81
    Best Answers:
    1
    Trophy Points:
    250
    #3
    kool but it doesn't list the {IMG} code and the HTML code.. can this be edited to show that?
     
    wvccboy, May 5, 2006 IP
  4. Edmunds

    Edmunds Peon

    Messages:
    136
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Edmunds, May 6, 2006 IP
  5. Shost

    Shost Peon

    Messages:
    5
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well please look the code

    #
    if (empty($error))
    #
    {
    #
    move_uploaded_file($_FILES['fmage']['tmp_name'],"".$_imagesdir."/$uploadfile");
    #
    $_OK="File uploaded :)";
    #
    }
    tranlating this : if no have error in upload the script upload the image ok ?

    you use the same validation in forms , logins systems ...

    if have error the script only return the message and no execute the action !
     
    Shost, May 6, 2006 IP