NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > Webmaster Tutorials
Reload this Page Simple PHP Upload Script [AND EXPLANATION]

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search
0 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 03-24-2006, 03:02 PM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse

Simple PHP Upload Script [AND EXPLANATION]


ALL Original scripts (no need to download) have been moved to this post!

NOTE: The latest versions are in this post for download!

-RageD

  • TODO List (v2)
    -Start/Finish Admin Panel
    -Allow admins to select what they wish their users to be able to upload.
^^^ Please give me suggestions for this list!

All scripts have been tested successfully!

DISCLAIMER: Some scripts are indeed insecure. Neither I nor Namepros.com can be held responsible for any hacking/attempts on your site or server.
Attached Files
File Type: zip Upload Script + Login.zip (2.8 KB, 89 views)
File Type: zip Upload Script + Login v1.15.zip (3.5 KB, 101 views)
File Type: zip Upload Script v1.15.zip (1.9 KB, 94 views)
File Type: zip Upload Script v2 - Preversion.zip (6.6 KB, 84 views)
Last edited by RageD; 12-21-2006 at 07:01 PM.
RageD is offline  
Old 03-24-2006, 03:10 PM   #2 (permalink)
Account Suspended
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Got any demos?
NetworkTown.Net is offline  
Old 03-24-2006, 03:12 PM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse

Original Post


Here is the original post:

PHP Code:
<?php
/* Upload Script by RageD
© 2006 RageD.  All Rights Reserved.
Filename: upload.php
File Info: Created by RageD.  Upload script for anyone who needs it
File Function: Uploads Files into a hidden directory (In this case by default '/uploads'
File Notes: Make sure your directory (whatever you make '$upload_dir' equal) is CHMODDED to 0777
Added Notes: You can place this file within a directory such as /public_html/uploads/upload_script and still have it upload files to /public_html/uploads (make sure it is CHMODDED 0777) all you have to do to do this is something like this: $upload_dir = "../"; or another directory within /public_html/uploads (directory qwerty for example) $upload_dir = "../qwerty";
*/

// Use this to define your upload directory!
$upload_dir "uploads";

if(!
$upload){
?>
<html>
<head>
<title>Upload Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="?upload=step2">
  <p>Enter the amount of boxes you will need below. Max = 99</p>
  <p>
    <input name="uploadNeed" type="text" id="uploadNeed" maxlength="2">
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
</body>
</html>
<?php
}
if(
$upload){
  if(
$upload == "step2"){ ?>
      <html>
      <head>
      <title>Upload Files</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      </head>

      <body>

      <form name="form1" enctype="multipart/form-data" method="post" action="?upload=process">
        <p>
        <?
        
// start of dynamic form
        
$uploadNeed $_POST['uploadNeed'];
        for(
$x=0;$x<$uploadNeed;$x++){
        
?>
          <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
        </p>
        <?
        
// end of for loop
        
}
        
?>
        <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
          <input type="submit" name="Submit" value="Submit">
        </p>
      </form>
      </body>
      </html>
<?php }
  if(
$upload == "process"){
      
$uploadNeed $_POST['uploadNeed'];
      
// start for loop
      
for($x=0;$x<$uploadNeed;$x++){
      
$file_name $_FILES['uploadFile'$x]['name'];
      
$show_file $_FILES['uploadFile'$x]['name'];
      
// strip file_name of slashes
      
$file_name stripslashes("$upload_dir/$file_name");
      
$file_name str_replace("'","",$file_name);
      
$copy copy($_FILES['uploadFile'$x]['tmp_name'],$file_name);
       
// check if successfully copied
       
if($copy){
       echo 
"$show_file | uploaded sucessfully!<br>";
       }else{
       echo 
"$show_file | could not be uploaded!<br>";
       }
      } 
// end of loop
   
}
}
?>
This one uploads directly to the directory the upload script is in! READ NOTES IN THE BEGINNING OF FILE!
PHP Code:
<?php
/* Upload Script by RageD
© 2006 RageD.  All Rights Reserved.
Filename: upload.php
File Info: Created by RageD.  Upload script for anyone who needs it
File Function: Uploads Files directly into directory of this script!
File Notes: Make sure your directory where this file is located is CHMODDED to 0777
*/

if(!$upload){
?>
<html>
<head>
<title>Upload Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="?upload=step2">
  <p>Enter the amount of boxes you will need below. Max = 99</p>
  <p>
    <input name="uploadNeed" type="text" id="uploadNeed" maxlength="2">
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
</body>
</html>
<?php
}
if(
$upload){
  if(
$upload == "step2"){ ?>
      <html>
      <head>
      <title>Upload Files</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      </head>

      <body>

      <form name="form1" enctype="multipart/form-data" method="post" action="?upload=process">
        <p>
        <?
        
// start of dynamic form
        
$uploadNeed $_POST['uploadNeed'];
        for(
$x=0;$x<$uploadNeed;$x++){
        
?>
          <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
        </p>
        <?
        
// end of for loop
        
}
        
?>
        <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
          <input type="submit" name="Submit" value="Submit">
        </p>
      </form>
      </body>
      </html>
<?php }
  if(
$upload == "process"){
      
$uploadNeed $_POST['uploadNeed'];
      
// start for loop
      
for($x=0;$x<$uploadNeed;$x++){
      
$file_name $_FILES['uploadFile'$x]['name'];
      
$show_file $_FILES['uploadFile'$x]['name'];
      
// strip file_name of slashes
      
$file_name stripslashes("$file_name");
      
$file_name str_replace("'","",$file_name);
      
$copy copy($_FILES['uploadFile'$x]['tmp_name'],$file_name);
       
// check if successfully copied
       
if($copy){
       echo 
"$show_file | uploaded sucessfully!<br>";
       }else{
       echo 
"$show_file | could not be uploaded!<br>";
       }
      } 
// end of loop
   
}
}
?>

This one shows the user where the file is uploaded to (The directory if you do not want it uploaded to the same directory as this script)
PHP Code:
<?php
/* Upload Script by RageD
© 2006 RageD.  All Rights Reserved.
Filename: upload.php
File Info: Created by RageD.  Upload script for anyone who needs it
File Function: Uploads Files into a directory other than the one the script is in!  Shows user the upload directory!
File Notes: Make sure your directory (whatever you make '$upload_dir' equal) is CHMODDED to 0777
Added Notes: You can place this file within a directory such as /public_html/uploads/upload_script and still have it upload files to /public_html/uploads (make sure it is CHMODDED 0777) all you have to do to do this is something like this: $upload_dir = "../"; or another directory within /public_html/uploads (directory qwerty for example) $upload_dir = "../qwerty";
*/

// Use this to define your upload directory!
$upload_dir "uploads";

if(!
$upload){
?>
<html>
<head>
<title>Upload Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="?upload=step2">
  <p>Enter the amount of boxes you will need below. Max = 99</p>
  <p>
    <input name="uploadNeed" type="text" id="uploadNeed" maxlength="2">
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
</body>
</html>
<?php
}
if(
$upload){
  if(
$upload == "step2"){ ?>
      <html>
      <head>
      <title>Upload Files</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      </head>

      <body>

      <form name="form1" enctype="multipart/form-data" method="post" action="?upload=process">
        <p>
        <?
        
// start of dynamic form
        
$uploadNeed $_POST['uploadNeed'];
        for(
$x=0;$x<$uploadNeed;$x++){
        
?>
          <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
        </p>
        <?
        
// end of for loop
        
}
        
?>
        <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
          <input type="submit" name="Submit" value="Submit">
        </p>
      </form>
      </body>
      </html>
<?php }
  if(
$upload == "process"){
      
$uploadNeed $_POST['uploadNeed'];
      
// start for loop
      
for($x=0;$x<$uploadNeed;$x++){
      
$file_name $_FILES['uploadFile'$x]['name'];
      
// strip file_name of slashes
      
$file_name stripslashes("$upload_dir/$file_name");
      
$file_name str_replace("'","",$file_name);
      
$copy copy($_FILES['uploadFile'$x]['tmp_name'],$file_name);
       
// check if successfully copied
       
if($copy){
       echo 
"$file_name | uploaded sucessfully!<br>";
       }else{
       echo 
"$file_name | could not be uploaded!<br>";
       }
      } 
// end of loop
   
}
}
?>
-RageD


For webservers running PHP version 4.x+ add these lines somewhere near the top somewhere.

PHP Code:
// Define our URL extension
$upload $_GET['upload']; 
========
Add-ons
========

  • Accept .gif files only

    Add
    PHP Code:
          $file_type $_FILES['uploadFile'$x]['type'];
          if(
    $file_type != "image/gif"){
                echo(
    "The server is only accepting .gif files!");
                exit;
           } 
    Before
    PHP Code:
          $file_name $_FILES['uploadFile'$x]['name']; 
    That works for any of the files... Here is the exact "upload4.php" example:
    PHP Code:
      <?php
    /* Upload Script by RageD
    © 2006 RageD.  All Rights Reserved.
    Filename: upload.php
    File Info: Created by RageD.  Upload script for anyone who needs it
    File Function: This is just like the example 3 script except it only allows .gif files
    File Notes: Make sure your directory (whatever you make '$upload_dir' equal) is CHMODDED to 0777
    Added Notes: You can place this file within a directory such as /public_html/uploads/upload_script and still have it upload files to /public_html/uploads (make sure it is CHMODDED 0777) all you have to do to do this is something like this: $upload_dir = "../"; or another directory within /public_html/uploads (directory qwerty for example) $upload_dir = "../qwerty";
    */

    // Define Function for uploading..
    $upload $_GET['upload'];

    // Use this to define your upload directory!
    $upload_dir "uploads";

    if(!
    $upload){
    ?>
    <html>
    <head>
    <title>Upload Files --- Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form name="form1" method="post" action="?upload=step2">
      <p>Enter the amount of boxes you will need below. Max = 99</p>
      <p>
        <input name="uploadNeed" type="text" id="uploadNeed" maxlength="2">
      </p>
      <p>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form>
    </body>
    </html>
    <?php
    }
    if(
    $upload){
      if(
    $upload == "step2"){ ?>
          <html>
          <head>
          <title>Upload Files</title>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          </head>

          <body>

          <form name="form1" enctype="multipart/form-data" method="post" action="?upload=process">
            <p>
            <?
            
    // start of dynamic form
            
    $uploadNeed $_POST['uploadNeed'];
            for(
    $x=0;$x<$uploadNeed;$x++){
            
    ?>
              <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
            </p>
            <?
            
    // end of for loop
            
    }
            
    ?>
            <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
              <input type="submit" name="Submit" value="Submit">
            </p>
          </form>
          </body>
          </html>
    <?php }
      if(
    $upload == "process"){
          
    $uploadNeed $_POST['uploadNeed'];
          
    // start for loop
          
    for($x=0;$x<$uploadNeed;$x++){
          
    $file_type $_FILES['uploadFile'$x]['type'];
          if(
    $file_type != "image/gif"){
                echo(
    "The server is only accepting .gif files!");
                exit;
           }
          
    $file_name $_FILES['uploadFile'$x]['name'];
          
    $show_file $_FILES['uploadFile'$x]['name'];
          
    // strip file_name of slashes
          
    $file_name stripslashes("$upload_dir/$file_name");
          
    $file_name str_replace("'","",$file_name);
          
    $copy copy($_FILES['uploadFile'$x]['tmp_name'],$file_name);
           
    // check if successfully copied
           
    if($copy){
           echo 
    "$show_file | uploaded sucessfully!<br>";
           }else{
           echo 
    "$show_file | could not be uploaded!<br>";
           }
          } 
    // end of loop
       
    }
    }
    ?>
  • Force users to register and login to upload

    This makes a user register and login before having the ability to upload files to the server! Requires PHP and MySQL.

    Open: file.php (Main upload script)

    Add: (On line 2)
    PHP Code:
    session_start(); 
    After: (On line 1)
    PHP Code:
    <?php
    Add:
    PHP Code:
    //Include DB Connections
    include("dbconn.php"); 
    After:
    PHP Code:
    // Use this to define your upload directory!
    $upload_dir "uploads"
    Now After:
    PHP Code:
    if(!$upload){
    ?> 
    Add:
    PHP Code:
    <html>
    <head>
    <title>Upload Files :: Login</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso8859-1">
    </head>

    <body>
    <form name="login" method="POST" action="?upload=login">
    Login Name: <input type="text" name="user"><br>
    Password: <input type="password" name="pass"><br>
    <input type=submit value="Login"><input type=reset>
    </form>
    <font size="2">Not registered?  <a href="?upload=register">Register</a> to upload!</font>
    </body>
    </html>
    <?php
    }
      if(
    $upload == "register"){
    ?>
    <html>
    <head>
    <title>Upload Files :: Login:</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso8859-1">
    </head>

    <body>
    <form name="login" method="POST" action="?upload=registerlogin">
    Login Name: <input type="text" name="uname"><br>
    Password: <input type="password" name="pass"><br>
    <input type=submit value="Signup"><input type=reset>
    </form>
    <font size="2">Not registered?  <a href="?page=register">Register</a> to upload!</font>
    </body>
    </html>
    <?php
    }
      if(
    $upload == "registerlogin"){
        
    $uname $_POST['uname'];
        
    $pass $_POST['pass'];
        if(!
    $uname || !$pass){
          echo(
    "Please enter all the fields!");
          exit;
        }
        function 
    do_error($msg)
        {
            echo 
    '<font color=red><b>ERROR <</font>'.$msg.'</b><br>Please go back to fix the error';
            exit;
        }
        @ 
    $r1 mysql_query("SELECT * FROM users WHERE username='$uname'");
        if (
    mysql_num_rows($r1) > 0)
        {
            
    do_error('That username is already taken.');
        }
            
    //MD5 Encrypt
            
    $pass md5($pass);
               
    $q "INSERT INTO users VALUES(NULL, '$uname', '$pass')";
        @ 
    $result mysql_query($q);
        
        if (!
    $result)
        {
            
    do_error('Could not insert into database. Error returned is '.mysql_error());
        }
        echo(
    "Thank you!  You can now <a href='?upload'>login</a>!");
      }
      if(
    $upload == "login"){
        
    $pass $_POST['pass'];
        
    $user $_POST['user'];
        
    $pass md5($pass);

        
    $q "SELECT * FROM users WHERE username='$user' AND password='$pass' LIMIT 1";
        
    $r mysql_query($q);
        
    //No matches
        
    if (mysql_num_rows($r) < 1)
        {
        echo(
    'Invalid username/password combination.');
        exit;
        }
        else
        {
            echo(
    "Logged in: Please go <a href='?upload=files'>here</a> to upload!");
            
            
    $_SESSION['username'] = $user;
        }
      }
      if(
    $upload == "files"){
      
    session_start();
      if(!
    $_SESSION['username']){
        echo(
    'You are not logged in. <a href="?upload">Login</a>');
        exit;
      }
    ?>
    Save & Close file.php (Main upload script)

    Now create a new file called "dbconn.php"

    Change the variables as needed:
    PHP Code:
    <?php
    /* Script by RageD to connect to MySQL DB */

    $conn mysql_connect('localhost''mysql_username_here''mysql_pass_here');
    $db mysql_select_db('mysql_dbname_here');

    if (!
    $conn || !$db)
    {
        echo(
    'Could not connect to database. Error returned is: '.mysql_error());
        exit;
    }
    ?>
    Save & Close dbconn.php

    Finally, create a database (MySQL) and insert this query:
    Code:
    CREATE TABLE `users` (
    `id` BIGINT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `username` VARCHAR( 16 ) NOT NULL ,
    `password` VARCHAR( 32 ) NOT NULL
    ) ENGINE = MYISAM CHARACTER SET latin1 COLLATE latin1_swedish_ci COMMENT = 'Everyone loves a databse :)'

    Here is a full working script (need dbconn.php and the MySQL query done for it to work) for this. It is the add-on plus the first script!

    PHP Code:
    <?php
    session_start
    ();
    /* Upload Script by RageD
    © 2006 RageD.  All Rights Reserved.
    Filename: upload.php
    File Info: Created by RageD.  Upload script for anyone who needs it
    File Function: Uploads Files into a hidden directory (In this case by default '/uploads'.  Forces a user to register and login!
    File Notes: Make sure your directory (whatever you make '$upload_dir' equal) is CHMODDED to 0777
    Added Notes: You can place this file within a directory such as /public_html/uploads/upload_script and still have it upload files to /public_html/uploads (make sure it is CHMODDED 0777) all you have to do to do this is something like this: $upload_dir = "../"; or another directory within /public_html/uploads (directory qwerty for example) $upload_dir = "../qwerty";
    */

    // Define URL extension
    $upload $_GET['upload'];

    // Use this to define your upload directory!
    $upload_dir "uploads";

    // Include DB connection
    include("dbconn.php");

    if(!
    $upload){
    ?>
    <html>
    <head>
    <title>Upload Files :: Login</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso8859-1">
    </head>

    <body>
    <form name="login" method="POST" action="?upload=login">
    Login Name: <input type="text" name="user"><br>
    Password: <input type="password" name="pass"><br>
    <input type=submit value="Login"><input type=reset>
    </form>
    <font size="2">Not registered?  <a href="?upload=register">Register</a> to upload!</font>
    </body>
    </html>
    <?php
    }
      if(
    $upload == "register"){
    ?>
    <html>
    <head>
    <title>Upload Files :: Login:</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso8859-1">
    </head>

    <body>
    <form name="login" method="POST" action="?upload=registerlogin">
    Login Name: <input type="text" name="uname"><br>
    Password: <input type="password" name="pass"><br>
    <input type=submit value="Signup"><input type=reset>
    </form>
    <font size="2">Not registered?  <a href="?page=register">Register</a> to upload!</font>
    </body>
    </html>
    <?php
    }
      if(
    $upload == "registerlogin"){
        
    $uname $_POST['uname'];
        
    $pass $_POST['pass'];
        if(!
    $uname || !$pass){
          echo(
    "Please enter all the fields!");
          exit;
        }
        function 
    do_error($msg)
        {
            echo 
    '<font color=red><b>ERROR <</font>'.$msg.'</b><br>Please go back to fix the error';
            exit;
        }
        @ 
    $r1 mysql_query("SELECT * FROM users WHERE username='$uname'");
        if (
    mysql_num_rows($r1) > 0)
    ????: NamePros.com http://www.namepros.com/webmaster-tutorials/180173-simple-php-upload-script-and-explanation.html
        {
            
    do_error('That username is already taken.');
        }
            
    //MD5 Encrypt
            
    $pass md5($pass);
               
    $q "INSERT INTO users VALUES(NULL, '$uname', '$pass')";
        @ 
    $result mysql_query($q);
        
        if (!
    $result)
        {
            
    do_error('Could not insert into database. Error returned is '.mysql_error());
        }
        echo(
    "Thank you!  You can now <a href='?upload'>login</a>!");
      }
      if(
    $upload == "login"){
        
    $pass $_POST['pass'];
        
    $user $_POST['user'];
        
    $pass md5($pass);

        
    $q "SELECT * FROM users WHERE username='$user' AND password='$pass' LIMIT 1";
        
    $r mysql_query($q);
        
    //No matches
        
    if (mysql_num_rows($r) < 1)
        {
        echo(
    'Invalid username/password combination.');
        exit;
        }
        else
        {
            echo(
    "Logged in: Please go <a href='?upload=files'>here</a> to upload!");
            
            
    $_SESSION['username'] = $user;
        }
      }
      if(
    $upload == "files"){
      
    session_start();
      if(!
    $_SESSION['username']){
        echo(
    'You are not logged in. <a href="?upload">Login</a>');
        exit;
      }
    ?>
    <html>
    <head>
    <title>Upload Files</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form name="form1" method="post" action="?upload=step2">
      <p>Enter the amount of boxes you will need below. Max = 99</p>
      <p>
        <input name="uploadNeed" type="text" id="uploadNeed" maxlength="2">
      </p>
      <p>
        <input type="submit" name="Submit" value="Submit">
      </p>
    </form>
    </body>
    </html>
    <?php
    }
    if(
    $upload){
      if(
    $upload == "step2"){ ?>
          <html>
          <head>
          <title>Upload Files</title>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          </head>

          <body>

          <form name="form1" enctype="multipart/form-data" method="post" action="?upload=process">
            <p>
            <?
            
    // start of dynamic form
            
    $uploadNeed $_POST['uploadNeed'];
            for(
    $x=0;$x<$uploadNeed;$x++){
            
    ?>
              <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
            </p>
            <?
            
    // end of for loop
            
    }
            
    ?>
            <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
              <input type="submit" name="Submit" value="Submit">
            </p>
          </form>
          </body>
          </html>
    <?php }
      if(
    $upload == "process"){
          
    $uploadNeed $_POST['uploadNeed'];
          
    // start for loop
          
    for($x=0;$x<$uploadNeed;$x++){
    ????: NamePros.com http://www.namepros.com/showthread.php?t=180173
          
    $file_name $_FILES['uploadFile'$x]['name'];
          
    $show_file $_FILES['uploadFile'$x]['name'];
          
    // strip file_name of slashes
          
    $file_name stripslashes("$upload_dir/$file_name");
          
    $file_name str_replace("'","",$file_name);
          
    $copy copy($_FILES['uploadFile'$x]['tmp_name'],$file_name);
           
    // check if successfully copied
           
    if($copy){
           echo 
    "$show_file | uploaded sucessfully!<br>";
           }else{
           echo 
    "$show_file | could not be uploaded!<br>";
           }
          } 
    // end of loop
       
    }
    }
    ?>
    Allow only: .zip, .rar, .jpg, .gif, .bmp, .png, & .txt extensions!

    This modification is too big just for a simple modding, so I have provided 2 downloads.

    1 with Login + this
    and one with NO login!
    Note: These scripts can be found in the v1.15 series!
Last edited by RageD; 12-21-2006 at 07:00 PM. Reason: This is the Original Post
RageD is offline  
Old 03-24-2006, 03:18 PM   #4 (permalink)
Account Suspended
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Ok ill be waiting
NetworkTown.Net is offline  
Old 03-24-2006, 03:19 PM THREAD STARTER               #5 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
Added!

-RageD
RageD is offline  
Old 03-28-2006, 02:54 AM   #6 (permalink)
NamePros Member
Join Date: Mar 2006
Posts: 29
XwaR is an unknown quantity at this point
 



Awesom stuff..........
XwaR is offline  
Old 03-28-2006, 03:39 AM   #7 (permalink)
NamePros Legend
 
weblord's Avatar
Join Date: Dec 2005
Location: Philippines - www.Nabaza.com
Posts: 19,784
weblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatness
 


Autism Protect Our Planet
that's great stuff, just what i need, rep coming your way. thanks.
__________________
Nabaza.com - Amaia
weblord is offline  
Old 04-01-2006, 06:19 AM   #8 (permalink)
Account Suspended
 
sb225's Avatar
Join Date: Feb 2006
Posts: 3,451
sb225 is a name known to allsb225 is a name known to allsb225 is a name known to allsb225 is a name known to allsb225 is a name known to allsb225 is a name known to all
 



great stuff
sb225 is offline  
Old 04-01-2006, 09:34 AM THREAD STARTER               #9 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
Glad you guys like it If you need something else, tell me.. If it is relavant to this I'll add it here or make a new post!

-RageD
RageD is offline  
Old 04-01-2006, 02:16 PM   #10 (permalink)
Ray
CEO
 
Ray's Avatar
Join Date: Jun 2005
Location: Tennessee
Posts: 1,896
Ray has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud ofRay has much to be proud of
 



nice tut mate...
Ray is offline  
Old 04-07-2006, 09:40 AM   #11 (permalink)
Account Suspended
Join Date: Dec 2005
Posts: 20
santro is an unknown quantity at this point
 



Superb!

"Uploads Files into a hidden directory "

Is is absolutely hidden?
santro is offline  
Old 04-07-2006, 02:10 PM   #12 (permalink)
NamePros Member
Join Date: Apr 2005
Posts: 117
mikesherov will become famous soon enoughmikesherov will become famous soon enough
 



Be careful when using this script, as it does not check for file extension, nor virus check, nor protect the files it stores. Someone could easily upload any .exe or virus or .php script using this, and then access it easily.

Otherwise, nice tutorial.
mikesherov is offline  
Old 04-07-2006, 06:38 PM THREAD STARTER               #13 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
I know. If people want, I could also post an extension limited version as well I'll work on adding it! And the hidden directory is unknown to the user..

-RageD
RageD is offline  
Old 04-07-2006, 11:51 PM   #14 (permalink)
Senior Member
 
bbalegere's Avatar
Join Date: Jul 2005
Location: Bangalore
Posts: 1,270
bbalegere is just really nicebbalegere is just really nicebbalegere is just really nicebbalegere is just really nicebbalegere is just really nice
 



Great scripts.
Keep it up.
bbalegere is offline  
Old 06-03-2006, 06:54 PM   #15 (permalink)
NamePros Expert
 
redhippo's Avatar
Join Date: Oct 2003
Location: ANForum
Posts: 5,218
redhippo is a splendid one to beholdredhippo is a splendid one to beholdredhippo is a splendid one to beholdredhippo is a splendid one to beholdredhippo is a splendid one to beholdredhippo is a splendid one to beholdredhippo is a splendid one to beholdredhippo is a splendid one to behold
 



cool nifty script..!!!!!!looking for one that can display random or recent images of those uploaded images on the web page itself
__________________
|www.vb-skins.com|- Quality Premade Vbulletin skins for Your VB forum makeover |www.Banjir.com|-Free image hosting?[B]For Sale!|AlphaScripts|Money Generating Scripts
FREE VB Skins
redhippo is offline  
Old 06-04-2006, 08:54 AM THREAD STARTER               #16 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
redhippo: I'll work on a script like that Look for a new post on it soon!

-RageD
RageD is offline  
Old 06-04-2006, 04:26 PM   #17 (permalink)
New Member
Join Date: May 2006
Posts: 6
Coron is an unknown quantity at this point
 



Really nice script RageD keep up the good work!
Coron is offline  
Old 07-12-2006, 08:01 PM THREAD STARTER               #18 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
Added a line to fix page change errors..

-RageD
RageD is offline  
Old 07-19-2006, 11:34 PM   #19 (permalink)
NamePros Member
Join Date: Nov 2005
Posts: 91
.root is an unknown quantity at this point
 



The first script works like a charm!
__________________
Review the rules...
.root is offline  
Old 07-28-2006, 08:25 AM   #20 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
great tutorial bro..but the demo links are not opening
unknowngiver is offline  
Old 07-28-2006, 10:17 AM THREAD STARTER               #21 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
Fixed the demos, adding some add-ons in a bit too!

-RageD

EDIT: added the add-on to accept only .gif files!
Last edited by RageD; 07-28-2006 at 11:04 AM.
RageD is offline  
Old 07-29-2006, 09:13 PM   #22 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Demo 2 error:

Parse error: syntax error, unexpected '[' in /home/xero/public_html/demos/upload2.php on line 11
unknowngiver is offline  
Old 07-29-2006, 10:33 PM THREAD STARTER               #23 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
Thanks for pointing that out unknowngiver! It has been fixed!

-RageD
RageD is offline  
Old 07-29-2006, 11:37 PM   #24 (permalink)
NamePros Member
 
bquast's Avatar
Join Date: Nov 2005
Location: Hardisty, Alberta Canada
Posts: 179
bquast will become famous soon enough
 



Originally Posted by mikesherov
Be careful when using this script, as it does not check for file extension, nor virus check, nor protect the files it stores. Someone could easily upload any .exe or virus or .php script using this, and then access it easily.

Otherwise, nice tutorial.
well no duh, with an upload script there is always the mention of security, but considering the only thing they can upload is virus's that effect others if they get someone to download it, otherwise its only php scripts you will have to worry about..

Even still add a downloader for the files, I worked on a few uploader scripts myself and they are not hard to create look for tutorials and other info on the web php.net is a big help when it comes to uploading files and editing files.

Little edit to your first script, when file is uploaded successfully, this will return the url in a text box, just like imageshack.us does.

hope you don't mind that I did a tiny bit of editing RageD.
PHP Code:
  <?php
/* Upload Script by RageD
© 2006 RageD.  All Rights Reserved.
Filename: upload.php
File Info: Created by RageD.  Upload script for anyone who needs it
File Function: Uploads Files into a hidden directory (In this case by default '/uploads'
File Notes: Make sure your directory (whatever you make '$upload_dir' equal) is CHMODDED to 0777
Added Notes: You can place this file within a directory such as /public_html/uploads/upload_script and still have it upload files to /public_html/uploads (make sure it is CHMODDED 0777) all you have to do to do this is something like this: $upload_dir = "../"; or another directory within /public_html/uploads (directory qwerty for example) $upload_dir = "../qwerty";
*/

// Use this to define your upload directory!
$upload_dir "uploads";

//edit this so the link displays correcty, no trailing slashes!
$site "http://www.xiaohost.com"

if(!
$upload){
?>
<html>
<head>
<title>Upload Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="?upload=step2">
  <p>Enter the amount of boxes you will need below. Max = 99</p>
  <p>
    <input name="uploadNeed" type="text" id="uploadNeed" maxlength="2">
  </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
</body>
</html>
<?php
}
if(
$upload){
  if(
$upload == "step2"){ ?>
      <html>
????: NamePros.com http://www.namepros.com/showthread.php?t=180173
      <head>
      <title>Upload Files</title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      </head>

      <body>

      <form name="form1" enctype="multipart/form-data" method="post" action="?upload=process">
        <p>
        <?
        
// start of dynamic form
        
$uploadNeed $_POST['uploadNeed'];
        for(
$x=0;$x<$uploadNeed;$x++){
        
?>
          <input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
        </p>
        <?
        
// end of for loop
        
}
        
?>
        <p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
          <input type="submit" name="Submit" value="Submit">
        </p>
      </form>
      </body>
      </html>
<?php }
  if(
$upload == "process"){
      
$uploadNeed $_POST['uploadNeed'];
      
// start for loop
      
for($x=0;$x<$uploadNeed;$x++){
      
$file_name $_FILES['uploadFile'$x]['name'];
      
$show_file $_FILES['uploadFile'$x]['name'];
      
// strip file_name of slashes
      
$file_name stripslashes("$upload_dir/$file_name");
      
$file_name str_replace("'","",$file_name);
      
$copy copy($_FILES['uploadFile'$x]['tmp_name'],$file_name);
       
// check if successfully copied
       
if($copy){
       echo 
"$show_file | uploaded sucessfully!<br>";
    echo 
"Link To File: <textarea rows='1' name='select'     cols='140'>http://www.".$site."/".$upload_dir."/".$file_name."</textarea></p>";
????: NamePros.com http://www.namepros.com/showthread.php?t=180173
       }else{
       echo 
"$show_file | could not be uploaded!<br>";
       }
      } 
// end of loop
   
}
}
?>
Last edited by bquast; 07-29-2006 at 11:53 PM.
bquast is offline  
Old 08-01-2006, 04:10 AM   #25 (permalink)
New Member
Join Date: Aug 2006
Posts: 2
louisianos is an unknown quantity at this point
 



ill try this one
louisianos is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 12:58 AM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger