Uploads,files,directory,Check,cool,saif
Quick Search for:  in language:    
Uploads,files,directory,Check,cool,saif
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 73,711 lines
 Jobs: 9 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for PHP.
PWGen
By Flinn Mueller on 10/19


URHere
By Flinn Mueller on 10/19


MySQL Database Wrapper
By Merlin Corey on 10/16


Click here to see a screenshot of this code!PHP Calender System
By Charles Chadwick on 10/14

(Screen Shot)

Click here to see a screenshot of this code!A1 counter
By Michael Goh on 10/10

(Screen Shot)

Backup MySql
By Keyur Itchhaporia on 10/9


An Important Note About .inc Files
By Charles Chadwick on 10/9


^ A time Saver Script
By Darryl Porter on 10/9


A 1337 Phrase Maker
By Jason DeLuca on 10/8


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

File Upload For Linux

Print
Email
 
VB icon
Submitted on: 10/29/2000 8:04:58 PM
By: PHP Code Exchange  
Level: Intermediate
User Rating: Unrated
Compatibility:PHP 3.0, PHP 4.0

Users have accessed this code 7881 times.
 
 
     Uploads 4 files to /tmp directory. Check it out it is cool. by saif
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    //**************************************
    //     
    // Name: File Upload For Linux
    // Description:Uploads 4 files to /tmp d
    //     irectory. Check it out it is cool. by sa
    //     if
    // By: PHP Code Exchange
    //**************************************
    //     
    
    <?
    // This code only works on Linux-based s
    //     ervers ;)
    // Some lines, like this one, are longer
    //     than this window and may have wrapped; y
    //     ou can get the original, if necessary, a
    //     t the address shown in the code descript
    //     ion
    // File Upload Script for PHP/3 for Linu
    //     x
    // Released under the terms of the publi
    //     c GNU license
    // Based upon code written by Rasmus Ler
    //     dorf and Boaz Yahav
    // Modified for Linux by Saif Slatewala
    // E-mail: saif_slatewala@india.com
    // site :- http://systemprg.hypermart.ne
    //     t
    // You need to write-enable a directory,
    //     named "/tmp", below the one you place th
    //     is script in
    if($action1){// if files have been uploaded, process them
    ?> 
    <html>
    <head>
    <title>File Upload Results</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <p><font face="Arial, Helvetica, sans-serif"><font size="+1">File Upload Results</font><br><br>
    <?
    set_time_limit(60);// make reasonably sure the script does not time out on large files
    $path1 = AddSlashes("/tmp/"); // assign our path in a form PHP for Windows understands
    for($i = 0; $i < 4; $i++){// loop through the 4 possible files
    switch($i){// retrieve a file pointer from the temp directory
    case 0:
    $source = $file1;
    $source_name = $file1_name;
    break;
    case 1:
    $source = $file2;
    $source_name = $file2_name;
    break;
    case 2:
    $source = $file3;
    $source_name = $file3_name;
    break;
    case 3:
    $source = $file4;
    $source_name = $file4_name;
    break;
    }
    if(($source <> "none")&&($source <> "")){ // see if the file exists; non-existing file has name of "none"
    if($error1 <> 1){// no need to copy a file if directory not write-enabled
    $dest = $path1.$source_name; // append file name to our path
    if(copy($source,$dest)){ // copy the file from the temp directory to the upload directory, and test for success
    echo "$source_name has been uploaded<br>\n"; 
    }
    else {
    echo "Upload directory not write-enabled\n"; // you need to write-enable the upload directory
    $error1 = 1; // set flag
    }
    }
    unlink($source);// delete the file from the temp directory
    }
    }
    ?>
    <br><a href="upload.php3">Back</a>
    </font></p>
    </body>
    </html>
    <?
    }
    else {// else, prompt for the files
    // files will be uploaded into the serve
    //     r's temp directory for PHP
    ?>
    <html>
    <head>
    <title>File Upload</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <p><font face="Arial, Helvetica, sans-serif"><font size="+1">File Upload</font><br><br>
    If your browser is upload-enabled, you will see "Browse" (Netscape, Internet Explorer) or ". . ." (Opera) buttons below. Use them to select file(s) to upload, then click the "Upload" button. After the files have been uploaded, you will see a results screen.<br>
    <form method="post" enctype="multipart/form-data" action="upload.php3">
    <input type="hidden" name="MAX_FILE_SIZE" value="400000">
    <input type="hidden" name="action1" value="1">
    File 1: <input type="file" name="file1" size="30"><br>
    File 2: <input type="file" name="file2" size="30"><br>
    File 3: <input type="file" name="file3" size="30"><br>
    File 4: <input type="file" name="file4" size="30"><br><br>
    <input type="submit" value="Upload">
    </form>
    </font></p>
    </body>
    </html>
    <?
    }
    ?>


Other 198 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.