" /> Need php uploader help
Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    May 2008
    Location
    Newport
    Posts
    14
    Tokens
    0

    Default Need php uploader help

    ok well basicly, iv code'd an image uploader, and i have a template on the upload page but i cant get a template onto the uploader page.

    this is the code
    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>Ooop » Free Image Hosting</title>
    <style type="text/css">
    <!--
    body {
        background-image: url(top_bar.gif);
        background-repeat: repeat-x;
        margin-top: 170px;
    }
    .test {
        font-family: "myriad Pro";
        font-weight: bold;
        color: #244386;
    }
    .title {
        font-size: 24px;
        font-family: "myriad Pro";
        color: #244386;
        font-weight: bold;
        letter-spacing: -1.8px;
    }
    .footer {
        font-family: "myriad Pro";
        color: #244386;
        font-size: 12px;
        font-weight: bold;
        a:hover
    }
    .a:hover {
        font-family: "myriad Pro";
        color: #244386;
        font-size: 12px;
        font-weight: bold;
        text-decoration: underline;    
    }
    #logo {
        position:absolute;
        left:19px;
        top:31px;
        width:188px;
        height:56px;
        z-index:1;
        background:logo.png;
        background-image: url(logo.png);
    }
    -->
    </style>
    </head>
    <body>
    <div id="logo"></div>
    
    
    <!-- All the kinds of code you want to be outputed go here --><?
    // CONFIG
    $serverpath = "images/";
    $urltoimages = "http://ooop.co.uk/images";
    $maxsize = "5000000";
    $uniq = uniqid("");
    // CONFIG END
    
    $mode = $_GET['mode'];
    if ($mode == "") { $mode = "form"; }
    
    if ($mode == "form") {
    echo "<form enctype='multipart/form-data' method='post' action='?mode=upload'>\n";
    echo "Upload file: <input type='file' name='file'>\n";
    echo "<br><input type='submit' name='Submit' value='Upload'>\n";
    echo "<br>Maximum File Size: 5$maxsizeb MB";
    echo "<br>hi im drew, and i like ponys";
    echo "<br>$file";
    }
    
    
    
    
    
    
    
    if ($mode == "upload") {
    $file = $_FILES['file']['name'];
    $name = time() . substr($file, -4);
    
     $allowedfiles[] = "gif";
     $allowedfiles[] = "jpg";
     $allowedfiles[] = "jpeg";
     $allowedfiles[] = "jfef";
     $allowedfiles[] = "jpe";
     $allowedfiles[] = "png";
     $allowedfiles[] = "GIF";
     $allowedfiles[] = "JPG";
     $allowedfiles[] = "JPEG";
     $allowedfiles[] = "JFEF";
     $allowedfiles[] = "JPE";
     $allowedfiles[] = "PNG";
     $allowedfiles[] = "bmp";
     $allowedfiles[] = "BMP";
     $allowedfiles[] = "tif";
     $allowedfiles[] = "tiff";
     $allowedfiles[] = "TIF";
     $allowedfiles[] = "TIFF";
    
    
     if($_FILES['file']['size'] > $maxsize)
     {
      print "File size is too big - please reduce file size and try again.";
      }
      else {
      $path = "$serverpath/" . $name;
      foreach($allowedfiles as $allowedfile) {
     
      if ($done <> "yes") {
      if (file_exists($path)) {
       echo "A file with this name already exists - please rename the file and reupload.";
       exit;
      }
      }
     
      if (substr($file, -3) == $allowedfile) {
        move_uploaded_file($_FILES['file']['tmp_name'], "$path");
        $done = "yes";
        echo "<p></p>";
    ?>
    </span>
    <table width="656" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="3" class="title"><span class="title">
     File successfully uploaded</span></td>
      </tr>
      <tr>
        <td height="3" colspan="3"></td>
      </tr>
      <tr>
        <td height="3" colspan="3" bgcolor="#244386"></td>
      </tr>
      <tr>
        <td height="15" colspan="3"></td>
      </tr>
      <tr>
        <td colspan="3"><div align="center"><span class="test"><img src="<?php echo "$urltoimages/$name"?>" /></span></div></td>
      </tr>
      <tr>
        <td height="15" colspan="3"></td>
      </tr>
      <tr>
        <td width="92" height="22"><span class="test">Direct Link:</span></td>
        <td width="24" height="22"></td>
        <td width="540"><input name='direct' type='text' align='center' size='85' value='<?php echo "$urltoimages/$name" ?>' /></td>
      </tr>
      <tr>
        <td height="22"></td>
        <td height="22"></td>
        <td height="22"></td>
      </tr>
      <tr>
        <td><span class="test">IMG Code:</span></td>
        <td height="22"></td>
        <td><input name='imgcode' type='text' align='center' size='85' value='[IMG]<?php echo "$urltoimages/$name" ?>[/IMG]' /></td>
      </tr>
      <tr>
        <td height="22"></td>
        <td height="22"></td>
        <td height="22"></td>
      </tr>
      <tr>
        <td><span class="test">HTML Code:</span></td>
        <td height="22"></td>
        <td><input name='htmlcode' type='text' align='center' size='85' value='<a href="http://ooop.co.uk/"><img src="<?php echo "$urltoimages/$name" ?>"/></a>' /></td>
      </tr>
      <tr>
        <td height="22"></td>
        <td height="22"></td>
        <td height="22"></td>
      </tr>
      <tr>
        <td height="3" colspan="3" bgcolor="#244386"></td>
      </tr>
      <tr>
        <td height="22" colspan="3" valign="bottom"><div align="right"><span class="footer">About | Contact Us | Advertise | Jobs | Terms of Use</span></div></td>
      </tr>
    </table>
    <p><span class="title">
      <?php
               
        }
    
      }
    
    if ($done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
    }
    }
    
    ?>
    </span></p>
    
    
    </body>
    </html>
    and this is what i want to put on the uploader bit
    Code:
    <table width="836" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="0" colspan="5"></td>
      </tr>
      <tr>
        <td height="21" colspan="5" background="file:///C|/Users/Joshua/Ooop/Server/uploader_top.gif"></td>
      </tr>
      <tr>
        <td width="18" rowspan="5" background="file:///C|/Users/Joshua/Ooop/Server/uploader_left.gif"></td>
        <td width="300" rowspan="5" bgcolor="#294D96"><a href="http://accessories.skype.com/servlet/ControllerServlet?Action=DisplayPage&amp;Env=BASE&amp;Locale=en_GB&amp;SiteID=skypeeu&amp;id=ProductDetailsPage&amp;productID=78051200&amp;tduid=beffcf9c6674002cd6066a33033b2e6c" target="_blank"><img src="file:///C|/Users/Joshua/Ooop/Server/advert.gif" width="300" height="250" /></a></td>
        <td width="13" rowspan="5" bgcolor="#294D96"></td>
        <td valign="top" bgcolor="#294D96" class="title">Uploader</td>
        <td width="26" rowspan="5" background="file:///C|/Users/Joshua/Ooop/Server/uploader_right.gif"></td>
      </tr>
      <tr>
        <td height="5" bgcolor="#294D96"></td>
      </tr>
      <tr>
        <td height="3" bgcolor="#FFFFFF"></td>
      </tr>
      <tr>
        <td height="15" bgcolor="#294D96"></td>
      </tr>
      <tr>
        <td bgcolor="#294D96"><label></label></td>
      </tr>
      
      <tr bgcolor="#000000">
        <td height="26" colspan="5" background="file:///C|/Users/Joshua/Ooop/Server/uploader_bottom.gif" bgcolor="#FFFFFF"></td>
      </tr>
    </table>
    <table width="810" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="810" height="19" align="right" valign="bottom"><div align="right" class="style2">
          <div align="right"> About | Terms of Service                            | Jobs                            | Contact                            | Advertise</div>
        </div></td>
      </tr>
    </table>
    </body>
    </html>
    if you could merge the 2 togethor so it would work it would be a big help.

    and p.s im not very good at codeing more of a video man, so please dont go ripping me on how balls my code is.
    Peace, Love, Skate

  2. #2
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Well for a start all your image paths are relative t your C: Drive, so it wont work when uploaded..
    Coming and going...
    Highers are getting the better of me

  3. #3
    Join Date
    May 2008
    Location
    Newport
    Posts
    14
    Tokens
    0

    Default

    oo i know that, but i will change them later
    Peace, Love, Skate

  4. #4
    Join Date
    Feb 2008
    Location
    Derby
    Posts
    305
    Tokens
    0

    Default

    Call this w.e you like make sure its .html

    HTML Code:
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    Select your file: <input name="uploaded" type="file" /><br />
    <input type="submit" value="Upload" />
    </form>
    Name this file upload.php

    PHP Code:
    <?php 
    $target 
    "upload/"//I recommend you change this to the folder you want your images to go!
    $target $target basename$_FILES['uploaded']['name']) ;  
    $ok=1
     
    //The size:
    if ($uploaded_size 100

    print 
    "Oo thats massive!<br>"//Prints the error message because the file is too large!
    $ok=0

     
    //Here we check to see if he/she is trying to upload other file types.
     
    if ($uploaded_type =="text/php"

    print 
    "No php files here!<br>"
    $ok=0

     
    //We check for an error in $ok
    if ($ok==0

    print 
    "Your file wasn't uploaded, please try again!"

     
     
    //Now that thats sorted lets try upload the file.
     
    else 

      if(
    move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))  

    print 
    "Success! The file "basename$_FILES['uploadedfile']['name']). " has been uploaded"
    }  
    else 

    print 
    "Oops, there was a problem uploading the file, please try again!"

     } 
     
    ?>
    Last edited by =Collecting=; 05-05-2008 at 08:37 AM.
    Win rares and lots more on this thread http://www.habboxforum.com/showthread.php?t=479892
    www.habbo-hc.com -LOOKING FOR STAFF

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by =Collecting= View Post
    Call this w.e you like make sure its .html

    HTML Code:
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    Select your file: <input name="uploaded" type="file" /><br />
    <input type="submit" value="Upload" />
    </form>
    Name this file upload.php

    PHP Code:
    <?php 
    $target 
    "upload/"//I recommend you change this to the folder you want your images to go!
    $target $target basename$_FILES['uploaded']['name']) ;  
    $ok=1
     
    //The size:
    if ($uploaded_size 100

    print 
    "Oo thats massive!<br>"//Prints the error message because the file is too large!
    $ok=0

     
    //Here we check to see if he/she is trying to upload other file types.
     
    if ($uploaded_type =="text/php"

    print 
    "No php files here!<br>"
    $ok=0

     
    //We check for an error in $ok
    if ($ok==0

    print 
    "Your file wasn't uploaded, please try again!"

     
     
    //Now that thats sorted lets try upload the file.
     
    else 

      if(
    move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))  

    print 
    "Success! The file "basename$_FILES['uploadedfile']['name']). " has been uploaded"
    }  
    else 

    print 
    "Oops, there was a problem uploading the file, please try again!"

     } 
     
    ?>
    You didn't define uploaded size, or type.. your just assuming it is defined. Your also not checking your mimi-types right.

  6. #6
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Make index.php, insert into:

    PHP Code:
    <?php
    include( 'dbConfig.php' );
    include( 
    'imageClass.php' );

    $imgClass = new imageFunctions();

    if( !empty( 
    $_FILES ) )
    {
        
    $imgClass->uploadImage();
    }
    ?>
    <script type="text/javascript" src="javascript/xmlhttp.js"></script>
    <style type="text/css">
        body, input {
            font-size: 12px;
            font-family: Segoe UI, Arial, Helvetica, sans-serif;
        }
    </style>
    <form action="" method="post" enctype="multipart/form-data">
    <p>Upload:
        <input type="file" name="pictures" /> 
        <input type="file" name="pictures1" /> 
        <input type="file" name="pictures2" /> 
        <input type="file" name="pictures3" /> 
        <input type="file" name="pictures4" /> 
        <input type="submit" value="Upload" />
    </p>
    </form><br />
    <?php
    $imgClass
    ->doDisplayImages();
    ?>
    make dbConfig.php, insert into:
    PHP Code:
    <?php
    $db 
    mysql_connect'localhost''username''password' );
    if( 
    $db === false )
    {
        exit( 
    'Database has exploded, please contact your local hobo.' );
    }
    else
    {
        
    $data mysql_select_db'database' );
    }
    ?>
    change details as required.


    create file imageFClass.php, insert into:

    PHP Code:
    <?php
    class imageFunctions
    {
        function 
    uploadImage()
        {
            
            
    $allowedTypes = array( 'image/png' => null'image/gif' => null'image/jpeg' => null'image/pjpeg' => null );
            
            foreach( 
    $_FILES as $key => $value )
            {
                if( !empty( 
    $_FILES$key ][ 'name' ] ) )
                {
                    if( 
    $_FILES$key ][ 'error' ] == UPLOAD_ERR_OK )
                    {
                        if( 
    array_key_exists$_FILES$key ][ 'type' ], $allowedTypes ) )
                        {
                            
    $extension explode'.'$_FILES$key ][ 'name' ] );
                            
    $extension $extension[ ( sizeof$extension ) - ) ];
                            
    $this->moveImage$_FILES$key ][ 'tmp_name' ], $extension$_FILES$key ][ 'type' ] );
                        }
                        else
                        {
                            echo( 
    'Invalid file, type ( ' $_FILES$key ][ 'type' ] . ' ) ' );
                        }
                    }
                    else
                    {
                        echo( 
    'Couldn\'t upload file ( ' $_FILES$key ][ 'name' ] . ' ) ' );
                    }
                }
            }
        }
        
        function 
    moveImage$fileName$extension$type )
        {
            
    $newName '/full/path/to/images/dir/' time() . '.' $extension;
            if( !
    move_uploaded_file$fileName$newName ) )
            {
                echo( 
    'Could not move file.' );
            }
            
    $this->makeThumbnail$newName$type$locationName );
            
        }
        
        function 
    listImages()
        {
            
        }
        
        function 
    makeThumbnail$fileName$type$locationName )
        {
            
    $fileImgName $fileName;
            
    $fileThumbName preg_replace'#/images/#''/thumbnails/'$fileImgName );
            
    $dofirst = array( 'image/png' => 'imagecreatefrompng($fileImgName)''image/gif' => 'imagecreatefromgif($fileImgName)''image/jpeg' => 'imagecreatefromjpeg($fileImgName)''image/pjpeg' => 'imagecreatefromjpeg($fileImgName)' );
            
    $dosecond = array( 'image/png' => 'imagepng($destImage, $fileThumbName)''image/gif' => 'imagegif($destImage, $fileThumbName)''image/jpeg' => 'imagejpeg($destImage, $fileThumbName)''image/pjpeg' => 'imagejpeg($destImage, $fileThumbName)' );
            
            if( 
    array_key_exists$type$dofirst ) )
            {
                eval( 
    '$do = ' $dofirst$type ] . ';' );
                list( 
    $originalWidth$originalHeight ) = getimagesize$fileName );
                
    $newWidth 200;
                
    $newHeight 200;
                
                if( 
    $originalWidth $newWidth OR $originalHeight $newHeight )
                {
                    if( 
    $originalHeight $originalWidth OR $originalHeight == $originalWidth )
                    {
                        
    $getRatio $originalHeight $newHeight;
                    }
                    elseif( 
    $originalWidth $originalHeight )
                    {
                        
    $getRatio $originalWidth $newWidth;
                    }
                }
                else
                {
                    if( 
    copy$fileImgName$fileThumbName ) )
                    {
                        return 
    '';
                    }
                    return 
    false;
                }
                
    $newHeight round$originalHeight $getRatio );
                
    $newWidth round$originalWidth $getRatio );
                
                
    # Setup the new image
                
                
    if( $type == 'image/png' )
                {
                    
    $destImage imagecreatetruecolor$newWidth$newHeight );
                    
    imagesavealpha$destImagetrue );
                
                    
    $trans_colour imagecolorallocatealpha$destImage000127 );
                    
    imagefill$destImage00$trans_colour );
                }
                elseif( 
    $type == 'image/gif' )
                {
                    
    $destImage imagecreatetruecolor$newWidth$newHeight );
                }
                elseif( 
    $type == 'image/jpeg' OR $type == 'image/pjpeg' )
                {
                    
    $destImage imagecreatetruecolor$newWidth$newHeight );
                }
                
                
    # So now we have the thumbnail stuff.
                
    imagecopyresampled$destImage$do0000$newWidth$newHeight$originalWidth$originalHeight );
                
                eval( 
    $dosecond$type ] . ';' );
                
            }
            else
            {
                exit( 
    '***' );
            }
            
        }

        function 
    doDisplayImages()
        {
            
    $dir opendir'thumbnails' );
            
    $i 0;
            
    $htmlBegin = <<<HTML
            <table style="width: 100%; border-spacing: 6px;">
                <tr>
    HTML;
            while( 
    false !== ( $dirName readdir$dir ) ) )
            {
                
    $array[] = $dirName;
            }
            
    $array array_reverse$array );
            foreach( 
    $array  as $key => $dirName )
            {
                if( 
    $dirName != '.' AND $dirName != '..' )
                {
                    
    $i++;
                    
    $htmlBegin .= '<td style="width: 20%; height: 250px; background: #eeeeee; vertical-align: top; padding: 10px; text-align: center;"><div style="text-align: center; margin-bottom: 4px;"><img src="thumbnails/' $dirName '"></div>';
                    
    $htmlBegin .= '<input type="text" value="http://path/to/images/folder/' $dirName '" onclick="copy(this);">';
                    
    $htmlBegin .= '</td>';
                    if( 
    $i == )
                    {
                        
    $htmlBegin .= '</tr><tr>';
                        
    $i 0;
                    }
                }
            }
            echo( 
    $htmlBegin '</tr></table>' );
        }
    }
    ?>
    Last edited by Jewish Bear; 06-05-2008 at 02:52 AM.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  7. #7
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    Make index.php, insert into:

    PHP Code:
    <?php
    include( 'dbConfig.php' );
    include( 
    'imageClass.php' );

    $imgClass = new imageFunctions();

    if( !empty( 
    $_FILES ) )
    {
        
    $imgClass->uploadImage();
    }
    ?>
    <script type="text/javascript" src="javascript/xmlhttp.js"></script>
    <style type="text/css">
        body, input {
            font-size: 12px;
            font-family: Segoe UI, Arial, Helvetica, sans-serif;
        }
    </style>
    <form action="" method="post" enctype="multipart/form-data">
    <p>Upload:
        <input type="file" name="pictures" /> 
        <input type="file" name="pictures1" /> 
        <input type="file" name="pictures2" /> 
        <input type="file" name="pictures3" /> 
        <input type="file" name="pictures4" /> 
        <input type="submit" value="Upload" />
    </p>
    </form><br />
    <?php
    $imgClass
    ->doDisplayImages();
    ?>
    make dbConfig.php, insert into:
    PHP Code:
    <?php
    $db 
    mysql_connect'localhost''username''password' );
    if( 
    $db === false )
    {
        exit( 
    'Database has exploded, please contact your local hobo.' );
    }
    else
    {
        
    $data mysql_select_db'database' );
    }
    ?>
    change details as required.


    create file imageFClass.php, insert into:

    PHP Code:
    <?php
    class imageFunctions
    {
        function 
    uploadImage()
        {
            
            
    $allowedTypes = array( 'image/png' => null'image/gif' => null'image/jpeg' => null'image/pjpeg' => null );
            
            foreach( 
    $_FILES as $key => $value )
            {
                if( !empty( 
    $_FILES$key ][ 'name' ] ) )
                {
                    if( 
    $_FILES$key ][ 'error' ] == UPLOAD_ERR_OK )
                    {
                        if( 
    array_key_exists$_FILES$key ][ 'type' ], $allowedTypes ) )
                        {
                            
    $extension explode'.'$_FILES$key ][ 'name' ] );
                            
    $extension $extension[ ( sizeof$extension ) - ) ];
                            
    $this->moveImage$_FILES$key ][ 'tmp_name' ], $extension$_FILES$key ][ 'type' ] );
                        }
                        else
                        {
                            echo( 
    'Invalid file, type ( ' $_FILES$key ][ 'type' ] . ' ) ' );
                        }
                    }
                    else
                    {
                        echo( 
    'Couldn\'t upload file ( ' $_FILES$key ][ 'name' ] . ' ) ' );
                    }
                }
            }
        }
        
        function 
    moveImage$fileName$extension$type )
        {
            
    $newName '/full/path/to/images/dir/' time() . '.' $extension;
            if( !
    move_uploaded_file$fileName$newName ) )
            {
                echo( 
    'Could not move file.' );
            }
            
    $this->makeThumbnail$newName$type$locationName );
            
        }
        
        function 
    listImages()
        {
            
        }
        
        function 
    makeThumbnail$fileName$type$locationName )
        {
            
    $fileImgName $fileName;
            
    $fileThumbName preg_replace'#/images/#''/thumbnails/'$fileImgName );
            
    $dofirst = array( 'image/png' => 'imagecreatefrompng($fileImgName)''image/gif' => 'imagecreatefromgif($fileImgName)''image/jpeg' => 'imagecreatefromjpeg($fileImgName)''image/pjpeg' => 'imagecreatefromjpeg($fileImgName)' );
            
    $dosecond = array( 'image/png' => 'imagepng($destImage, $fileThumbName)''image/gif' => 'imagegif($destImage, $fileThumbName)''image/jpeg' => 'imagejpeg($destImage, $fileThumbName)''image/pjpeg' => 'imagejpeg($destImage, $fileThumbName)' );
            
            if( 
    array_key_exists$type$dofirst ) )
            {
                eval( 
    '$do = ' $dofirst$type ] . ';' );
                list( 
    $originalWidth$originalHeight ) = getimagesize$fileName );
                
    $newWidth 200;
                
    $newHeight 200;
                
                if( 
    $originalWidth $newWidth OR $originalHeight $newHeight )
                {
                    if( 
    $originalHeight $originalWidth OR $originalHeight == $originalWidth )
                    {
                        
    $getRatio $originalHeight $newHeight;
                    }
                    elseif( 
    $originalWidth $originalHeight )
                    {
                        
    $getRatio $originalWidth $newWidth;
                    }
                }
                else
                {
                    if( 
    copy$fileImgName$fileThumbName ) )
                    {
                        return 
    '';
                    }
                    return 
    false;
                }
                
    $newHeight round$originalHeight $getRatio );
                
    $newWidth round$originalWidth $getRatio );
                
                
    # Setup the new image
                
                
    if( $type == 'image/png' )
                {
                    
    $destImage imagecreatetruecolor$newWidth$newHeight );
                    
    imagesavealpha$destImagetrue );
                
                    
    $trans_colour imagecolorallocatealpha$destImage000127 );
                    
    imagefill$destImage00$trans_colour );
                }
                elseif( 
    $type == 'image/gif' )
                {
                    
    $destImage imagecreatetruecolor$newWidth$newHeight );
                }
                elseif( 
    $type == 'image/jpeg' OR $type == 'image/pjpeg' )
                {
                    
    $destImage imagecreatetruecolor$newWidth$newHeight );
                }
                
                
    # So now we have the thumbnail stuff.
                
    imagecopyresampled$destImage$do0000$newWidth$newHeight$originalWidth$originalHeight );
                
                eval( 
    $dosecond$type ] . ';' );
                
            }
            else
            {
                exit( 
    '***' );
            }
            
        }

        function 
    doDisplayImages()
        {
            
    $dir opendir'thumbnails' );
            
    $i 0;
            
    $htmlBegin = <<<HTML
            <table style="width: 100%; border-spacing: 6px;">
                <tr>
    HTML;
            while( 
    false !== ( $dirName readdir$dir ) ) )
            {
                
    $array[] = $dirName;
            }
            
    $array array_reverse$array );
            foreach( 
    $array  as $key => $dirName )
            {
                if( 
    $dirName != '.' AND $dirName != '..' )
                {
                    
    $i++;
                    
    $htmlBegin .= '<td style="width: 20%; height: 250px; background: #eeeeee; vertical-align: top; padding: 10px; text-align: center;"><div style="text-align: center; margin-bottom: 4px;"><img src="thumbnails/' $dirName '"></div>';
                    
    $htmlBegin .= '<input type="text" value="http://path/to/images/folder/' $dirName '" onclick="copy(this);">';
                    
    $htmlBegin .= '</td>';
                    if( 
    $i == )
                    {
                        
    $htmlBegin .= '</tr><tr>';
                        
    $i 0;
                    }
                }
            }
            echo( 
    $htmlBegin '</tr></table>' );
        }
    }
    ?>
    That doesn't handle IE values.

  8. #8
    Join Date
    Apr 2008
    Location
    England.
    Posts
    1,324
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by =Collecting= View Post
    Call this w.e you like make sure its .html

    HTML Code:
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    Select your file: <input name="uploaded" type="file" /><br />
    <input type="submit" value="Upload" />
    </form>
    Name this file upload.php

    PHP Code:
    <?php 
    $target 
    "upload/"//I recommend you change this to the folder you want your images to go!
    $target $target basename$_FILES['uploaded']['name']) ;  
    $ok=1
     
    //The size:
    if ($uploaded_size 100

    print 
    "Oo thats massive!<br>"//Prints the error message because the file is too large!
    $ok=0

     
    //Here we check to see if he/she is trying to upload other file types.
     
    if ($uploaded_type =="text/php"

    print 
    "No php files here!<br>"
    $ok=0

     
    //We check for an error in $ok
    if ($ok==0

    print 
    "Your file wasn't uploaded, please try again!"

     
     
    //Now that thats sorted lets try upload the file.
     
    else 

      if(
    move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))  

    print 
    "Success! The file "basename$_FILES['uploadedfile']['name']). " has been uploaded"
    }  
    else 

    print 
    "Oops, there was a problem uploading the file, please try again!"

     } 
     
    ?>
    Copied off of urtut:rolleyes:

    Quote Originally Posted by Dentafrice View Post
    You didn't define uploaded size, or type.. your just assuming it is defined. Your also not checking your mimi-types right.
    Thats because he's faking to know how to code.

  9. #9
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Well anyway, it is awful. You don't have to save as HTML first, how stupid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •