+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: [PHP] Creating a File Upload Script

  1. #11
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Creating a File Upload Script

    Quote Originally Posted by o0slowpaul0o
    Hmmm. I know. I got it from there, didn't say it was mine.
    Please give credit in the post when it comes from some where else :grin:
    Corey Arbogast | CEO
    █ 888-X10-9668 - corey[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

  2. #12
    symbianclub is offline x10Hosting Member symbianclub is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    In My Home
    Posts
    40

    Re: [PHP] Creating a File Upload Script

    Good Cool Script

  3. #13
    Vietkid58's Avatar
    Vietkid58 is offline x10 Sophmore Vietkid58 is an unknown quantity at this point
    Join Date
    Jul 2005
    Posts
    225

    Re: [PHP] Creating a File Upload Script

    do u have a demo to how it works?

  4. #14
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: [PHP] Creating a File Upload Script

    "This" has happened more then once now.. You take a tutorial from another site and act as if it if yours. Just give credit to the people who make/made them, it's not that hard.

    To get back on topic.. I found a nice file upload function/form on php.net. All you have to do is echo teh function, and it's all set up nice. Has multiple options for the "amount" of files, teh directory, the max upload size, etc. Let me check.


    Edit:



    dmsuperman at comcast dot net
    26-Apr-2005 11:00 I needed a file uploader for a client a little while ago, then the client didn't want it, so I'll share with all of you. I know I hated coding it, it was confusing (for me anyway), but I made it fairly simple to use:


    PHP Code:
    <?
    function uploader($num_of_uploads=1$file_types_array=array("txt"), $max_file_size=1048576$upload_dir=""){
      if(!
    is_numeric($max_file_size)){
        
    $max_file_size 1048576;
      }
      if(!isset(
    $_POST["submitted"])){
    $form "<form action='".$PHP_SELF."' method='post' enctype='multipart/form-data'>Upload files:<br /><input type='hidden' name='submitted' value='TRUE' id='".time()."'><input type='hidden' name='MAX_FILE_SIZE' value='".$max_file_size."'>";
        for(
    $x=0;$x<$num_of_uploads;$x++){
          
    $form .= "<input type='file' name='file[]'><font color='red'>*</font><br />";
        }
    $form .= "<input type='submit' value='Upload'><br /><font color='red'>*</font>Maximum file length (minus extension) is 15 characters. Anything over that will be cut to only 15 characters. Valid file type(s): ";
        for(
    $x=0;$x<count($file_types_array);$x++){
          if(
    $x<count($file_types_array)-1){
            
    $form .= $file_types_array[$x].", ";
          }else{
            
    $form .= $file_types_array[$x].".";
          }
        }
        
    $form .= "</form>";
        echo(
    $form);
      }else{
        foreach(
    $_FILES["file"]["error"] as $key => $value){
          if(
    $_FILES["file"]["name"][$key]!=""){
            if(
    $value==UPLOAD_ERR_OK){
              
    $origfilename $_FILES["file"]["name"][$key];
              
    $filename explode("."$_FILES["file"]["name"][$key]);
              
    $filenameext $filename[count($filename)-1];
              unset(
    $filename[count($filename)-1]);
              
    $filename implode("."$filename);
              
    $filename substr($filename015).".".$filenameext;
              
    $file_ext_allow FALSE;
              for(
    $x=0;$x<count($file_types_array);$x++){
                if(
    $filenameext==$file_types_array[$x]){
                  
    $file_ext_allow TRUE;
                }
              }
              if(
    $file_ext_allow){
                if(
    $_FILES["file"]["size"][$key]<$max_file_size){
                 if(
    move_uploaded_file($_FILES["file"]["tmp_name"][$key], $upload_dir.$filename)){
                 echo(
    "File uploaded successfully. - <a href='".$upload_dir.$filename."' target='_blank'>".$filename."</a><br />");
                  }else{
                 echo(
    $origfilename." was not successfully uploaded<br />");
                  }
                }else{
                 echo(
    $origfilename." was too big, not uploaded<br />");
                }
              }else{
             echo(
    $origfilename." had an invalid file extension, not uploaded<br />");
              }
            }else{
              echo(
    $origfilename." was not successfully uploaded<br />");
            }
          }
        }
      }
    }
    ?>

    uploader([int num_uploads [, arr file_types [, int file_size [, str upload_dir ]]]]);

    num_uploads = Number of uploads to handle at once.

    file_types = An array of all the file types you wish to use. The default is txt only.

    file_size = The maximum file size of EACH file. A non-number will results in using the default 1mb filesize.

    upload_dir = The directory to upload to, make sure this ends with a /

    This functions echo()'s the whole uploader, and submits to itself, you need not do a thing but put uploader(); to have a simple 1 file upload with all defaults.

    http://us2.php.net/manual/en/feature...load.php#52268
    Last edited by Bryon; 09-09-2005 at 06:24 PM.

  5. #15
    Aswin is offline x10Hosting Member Aswin is an unknown quantity at this point
    Join Date
    Sep 2005
    Posts
    6

    Re: [PHP] Creating a File Upload Script

    very nice tutorials thx but is there any way to learn php as i m a newbie

  6. #16
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: [PHP] Creating a File Upload Script

    phpfreaks.com
    php.net

    Both will help you if your serious...

  7. #17
    Mani5 is offline x10 Lieutenant Mani5 is an unknown quantity at this point
    Join Date
    Sep 2005
    Posts
    473

    Re: [PHP] Creating a File Upload Script

    nice! all u guyz who ever copied it off a site (i dont care) and whoever is da author od da script..

    Thanx!
    Last edited by Mani5; 09-30-2005 at 10:02 AM.

  8. #18
    symbianclub is offline x10Hosting Member symbianclub is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    In My Home
    Posts
    40

    Re: [PHP] Creating a File Upload Script

    good script
    HTML Code:
    [url=http://www.symbianclub.x10hosting.com]Visit My Site
    [/url]
    WANT TO ADVERTISE ON MY SITE THEN PM ME
    ================:sleep2:

    Rahul

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. file upload script
    By nightscream in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-11-2011, 05:04 PM
  2. Converting a .RMVB file
    By SEŅOR in forum Off Topic
    Replies: 7
    Last Post: 06-19-2006, 02:20 PM
  3. Simple Image Upload [PHP]
    By ak007 in forum Tutorials
    Replies: 1
    Last Post: 10-10-2005, 06:11 AM
  4. Upload file size limit
    By funindia in forum Free Hosting
    Replies: 0
    Last Post: 06-05-2005, 01:06 AM
  5. Creating a Card Game Script
    By Rhianna in forum Scripts & 3rd Party Apps
    Replies: 17
    Last Post: 05-30-2005, 03:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers