Posted By

smilylion on 09/04/06


Tagged

form upload


Versions (?)

Who likes this?

8 people have marked this snippet as a favorite

Roshambo
mdavie
oli964
JimiJay
crs0328
haozi
ninjacharlee
userpiv


php file upload from local


 / Published in: PHP
 

URL: http://de.php.net/manual/de/features.file-upload.php

  1. Beispiel 38-1. Formular für den Dateiupload
  2.  
  3. <form enctype="multipart/form-data" action="_URL_" method="post">
  4. <input type="hidden" name="MAX_FILE_SIZE" value="30000">
  5. Send this file: <input name="userfile" type="file">
  6. <input type="submit" value="Send File">
  7. </form>
  8.  
  9. Beispiel 38-2. Dateiuploads prüfen und saven
  10.  
  11. Weitere Informationen finden Sie auch in den Beschreibungen für is_uploaded_file() und move_uploaded_file(). Das folgende Beispiel verarbeitet einen von einem HTML-Formular kommenden Dateiupload.
  12. <?php
  13. // In PHP kleiner als 4.1.0 sollten Sie $HTTP_POST_FILES anstatt $_FILES verwenden.
  14. // In PHP kleiner als 4.0.3 verwenden Sie copy() und is_uploaded_file() anstatt von
  15. // move_uploaded_file()
  16.  
  17. $uploaddir = '/var/www/uploads/';
  18. print "<pre>";
  19. if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {
  20. print "File is valid, and was successfully uploaded. Here's some more debugging info:\n";
  21. print_r($_FILES);
  22. } else {
  23. print "Possible file upload attack! Here's some debugging info:\n";
  24. print_r($_FILES);
  25. }
  26.  
  27. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: JimiJay on January 31, 2008

You need to login to post a comment.