Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Location
    Fatherland
    Posts
    2,414
    Tokens
    0

    Latest Awards:

    Default Html Uploader Help +Rep

    Ok
    So im making a little uploader in html on dreamweaver.
    So i have the "choose file" tab where you click it and you choose which file you want to upload.
    Then i have a "upload" tab, but i carnt figure out how to make it make you go to a page where it shows your file and links to it?
    +Rep will be awarded to people who give advice that works.

    Thanks very much!
    -Jamie

  2. #2
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:


  3. #3
    Join Date
    May 2006
    Location
    Fatherland
    Posts
    2,414
    Tokens
    0

    Latest Awards:

    Default

    Thanks so much mate.
    +Rep!

  4. #4
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php

      
    # Not tested. Use at your own risk.

      
    $exts[] = 'jpg';
      
    $exts[] = 'jpeg';
      
    $exts[] = 'png';
      
    $exts[] = 'gif';
      
    $exts[] = 'txt';

      
    define('dir''files/');
      
    define('err''Opps! A problem occured.');
      
    define('seed''"!Fqi346kF2W_j*');


    if(
    $_POST['userfileupload']) {

      
    $tmpname $_FILES['userfile']['tmp_name'];
      
    $ext substr(strrchr(strtolower($_FILES['userfile']['name']), "."), 1);
      list(
    $width$height) = getimagesize($tmpname);
      
    $hash md5(seed.file_get_contents($tmpname));

      if(!
    is_uploaded_file($tmpname))die(err);
      if(
    $_FILES['userfile']['error']>0)die(err);
      if(!
    in_array($ext$exts))die(err);
      if(isset(
    $width)&&($width>1500||$height>1500))die(err);
      if(
    $_FILES['userfile']['size']>100000)die(err);

      if(!
    file_exists($dir.$hash.$ext)) copy($tmpnamedir.$hash.'.'.$ext);
      print(
    'File Uploaded');

    } else {
    $self htmlentities($_SERVER['PHP_SELF']);
    print <<<HTML
      <form method="POST" action="{$self}" enctype="multipart/form-data">
        <input type="file" name="userfile" /> 
        <input type="submit" name="userfileupload" />
      </form>

    HTML;
    }

    ?>
    I might have made some errors, and I'm not sure if it's 100&#37; secure, so use it at your own risk..
    Last edited by nets; 05-12-2006 at 05:46 PM.
    kinda quit.

Posting Permissions

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