Learning & Integrating web technology and code help directory

How to use PHP & File ($_FILES,$HTTP_POST_FILES)

No comments
How to use PHP & File ($_FILES,$HTTP_POST_FILES) Learn PHP how to using $_FILES and read a php variable , upload file
ShotDev Focus:
- Using $_FILES for upload file
Example
php_file1.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <form action="php_file2.php" method="post" enctype="multipart/form-data" name="form1">  
  7. <input type="file" name="fileUpload">  
  8. <input type="submit" name="Submit" value="Submit">  
  9. </form>  
  10. </body>  
  11. </html>  
php_file2.php

  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?php  
  7. echo "\$_FILES[\"fileUpload\"][\"name\"] = ".$_FILES["fileUpload"]["name"]."<br>";  
  8. echo "\$_FILES[\"fileUpload\"][\"type\"] = ".$_FILES["fileUpload"]["type"]."<br>";  
  9. echo "\$_FILES[\"fileUpload\"][\"size\"] = ".$_FILES["fileUpload"]["size"]."<br>";  
  10. echo "\$_FILES[\"fileUpload\"][\"tmp_name\"] = ".$_FILES["fileUpload"]["tmp_name"]."<br>";  
  11. echo "\$_FILES[\"fileUpload\"][\"error\"] = ".$_FILES["fileUpload"]["error"]."<br>";  
  12.   
  13. if(copy($_FILES["fileUpload"]["tmp_name"],"myfile/".$_FILES["fileUpload"]["name"])) // Upload/Copy  
  14. {  
  15. echo "Copy/Upload Completed.";  
  16. }  
  17. ?>  
  18. </body>  
  19. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP Upload file
PHP Upload file
PHP Upload file
PHP Upload file

No comments :

Post a Comment