Recent Posts

This Post Has Been Viewed 1,777 Times.

Simple file upload script using php

Posted by admin | Posted in PHP, scripts | Posted on 02-03-2009

2

Here i will explain a simple php script which will upload files to a particular directory specified.

  1.  
  2. <?php
  3. session_start();
  4. if(!isset($_POST['upload'])) {
  5. echo ‘
  6. <form name=”upload” enctype=”multipart/form-data” method=”POST” action=”‘.$_SERVER['REQUEST_URI'].’”>
  7. <input type=”file” name=”file” size=”13″ value=”">
  8. <br /><input type=”submit” name=”upload” value=”Upload”>
  9. </form>
  10. ‘;
  11. } else {
  12. $yourdomain = ‘http://localhost/’;
  13. $uploaddir = ‘uploads/’;
  14. $filename = $_FILES['file']['name'];
  15. $filesize = $_FILES['file']['size'];
  16. $tmpname_file = $_FILES['file']['tmp_name'];
  17.   
  18. if($filesize > ‘1000000′) {
  19. echo “Way too big!!”;
  20. } else {
  21. move_uploaded_file($tmpname_file, “$uploaddir$filename”);
  22. echo “Successful.<br /><b>URL: </b>”.$yourdomain.$uploaddir.$filename.”</textarea>”;
  23. }
  24.   }
  25. ?> 
VN:F [1.5.7_846]
Rating: 0.0/10 (0 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • Xerpi

Related posts:

  1. Simple PHP mail Script
  2. Simple PHP Login Script
  3. Simple php watermark script
  4. Upload Your Scripts For Free
  5. File System Reference In PHP
  6. Find Absolute Path Of A File Or Directory Using PHP
  7. Appending string using php to a text file

Comments (2)

Woow cool script

VA:F [1.5.7_846]
Rating: 0.0/5 (0 votes cast)
VA:F [1.5.7_846]
Rating: 0 (from 0 votes)

good one for script uopload

VA:F [1.5.7_846]
Rating: 0.0/5 (0 votes cast)
VA:F [1.5.7_846]
Rating: 0 (from 0 votes)

Write a comment

Spam Protected