开发者

How to make a upload script in one page only?

Can anyone give a sam开发者_StackOverflow社区ple of an upload script that will process the upload and the validations in one page? Or the concept/idea on how to make it. Thanks a lot!


Yes, you can do it in one PHP file. The general concept:

<?php

     if (empty($_FILES)) {   // or check for $_POST["submit-button"]

          // print form
          ?>...<input type=file name=upload>...<?php

     }
     else {

          // process form
          move_uploaded_file($_FILES["upload"]["tmp_name"], ...);

     }

All the other details are mentioned in http://www.php.net/manual/en/features.file-upload.post-method.php, and in the heaps of existing tutorials on PHP file uploads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜