当前位置:  开发笔记 > 编程语言 > 正文

如何上传包含用户名,密码,多个文件上传的HTML表单,然后使用PHP进行处理?

如何解决《如何上传包含用户名,密码,多个文件上传的HTML表单,然后使用PHP进行处理?》经验,为你挑选了1个好方法。

如何从单个html表单发布用户名,密码和多个二进制文件并使用php处理它?我不允许使用ajax.



1> phatduckk..:

首先在PHP.net上查看这些页面

    文件上传信息

    move_uploaded_file

但是为了让你开始这里有几个存根文件.

uploadForm.html



    
username: password:




processStuff.php

Username & password'
    echo "Username: {$_POST['username']}\nPassword: {$_POST['password']}";
    echo '
'; echo '

Uploaded files

' foreach($_FILES['uploadFile']['tmp_name'] as $i => $tempUploadPath) { if (empty($tempUploadPath)) { // this was "blank"... no file selected } else { // a file was uploaded echo 'A file named "', $_FILES['uploadFile']['name'][$i], "\" was uploaded\n"; echo "\ttemporarily stored at: ", $tempUploadPath, "\n"; echo "\tmime type: ", $_FILES['uploadFile']['type'][$i], "\n"; echo "\tsize: ", $_FILES['uploadFile']['size'][$i], " bytes\n"; echo "\terror code", ((empty($_FILES['uploadFile']['size'][$i]) ? 'no errror' : $_FILES['uploadFile']['size'][$i])), "\n\n"; // do something useful with the uploaded file // access it via $tempUploadPath and use move_uploaded_file() to move // it out of the temp path before you manipulate it in any way!!!!! // see http://us3.php.net/features.file-upload // and http://us3.php.net/manual/en/function.move-uploaded-file.php } } ?>

这个HTML文件显示如何设置enctype

与第二种形式告诉您如何访问提交的用户名和密码及最后如何环路直通每个上传的文件.

如上所述,您必须尽快移动文件.它们被上传到临时位置,系统将删除它们,除非您处理它们.所以先把它们移到某个地方,然后随心所欲地做任何事情.

这有帮助

阿林

推荐阅读
跟我搞对象吧
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有