| 域名空间 下载中心 社区论坛 信息公告 my小屋 |
![]() |
联系我们 设为首页 加入收藏 |
|
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿 论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图 专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版 社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务 |
| 新版上线![旧版] | |||||
注:打开慢时请稍等
如何从表单中获得上传文件属性http://www.iyit.net 日期:2006-10-6 15:13:43 来源:iyit.net收集 点击: |
问题: 我做了一个表单index.html: <form method="post" action="process.php" enctype="multipart/form-data" name="form1"> <table> <tr> <td><input name="pic" type="file" size="30"></td> </tr> <tr> <td> <input name="submit" type="submit" id="submit" value="send"> <input type="reset" name="submit2" value="reset"> </td> </tr> </table> </form> 提交后的处理页process.php: <?php echo filetype($pic); echo basename($pic); ?> 我在file表单域打开一个图片文件,想输出文件名和类型,但是为什么总是不能输出,结果是输出文件名为:"c:\windows\temp\php2",而文件类型为:"file" 为什么不是我的文件所在的绝对路径,和我想得到的"jpeg"类型呢,请高手帮帮我. --------------------------------------------------------------- <?php include ("../../lib/setting.php");pangright($sas_session[userlogin][spwd]); if (count($http_post_vars)>0){ if(!empty($mydocfile)){ //echo "cp ".$attachfile." ".$mydocfile.$filename; copy($attachfile,$mydocfile.$filename); } if(!empty($gdocfile)){ //echo "cp ".$attachfile." ".$gdocfile.$filename; copy($attachfile,$gdocfile.$filename); } if(!empty($jishufile)){ //echo "cp ".$attachfile." ".$gdocfile.$filename; copy($attachfile,$jishufile.$filename); } } ?> <html> <head> <title> :::::: </title> <meta http-equiv="content-type" content="text/html; charset=<?php echo ${charset_.$sas_session[language]}; ?>"> <?php echo ${css_.$sas_session[language]}; ?> <script language="javascript"> function sendform(){ if(document.dataform.attachfile.value==''){ alert("请添加上传文件!"); document.dataform.attachfile.focus(); return false; } var fname=''; var str=document.dataform.attachfile.value; fname=str.split("\\"); document.dataform.filename.value=fname[fname.length-1]; document.dataform.submit(); } </script> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" > <center> <table width="95%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="td8"> <table width="0" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="td8" width="19"> </td> <td class="td8a"><b>文档管理--文件上传</b></td> <td class="td8" width="48"> </td> <td class="td8"> </td> </tr> </table> </td> <td width="10" class="td8"> </td> </tr> </table> </center> <form name="dataform" enctype="multipart/form-data" action="<?php echo $php_self;?>" method="post"> <input type="hidden" name="filename"> <center> <table width="95%" border="0" cellpadding="0" cellspacing="1" class="font12px"> <tr align="center"><td> <input type="checkbox" class="ip2" name="mydocfile" value="<?php echo $path->userfiles."/user/".$sas_session[userlogin][uloginid]."/";?>" <?php if(!empty($mydocfile) ¦ ¦(empty($mydocfile)&&empty($gdocfile)))echo "checked";?>> 上传到我的文件夹 <input type="checkbox" class="ip2" name="gdocfile" value="<?php echo $path->userfiles."/group/".$sas_session[userlogin][ugroupid]."/";?>" <?php if(!empty($gdocfile)) echo "checked";?>> 上传到部门文件夹 <input type="checkbox" class="ip2" name="jishufile" value="<?php echo $path->userfiles."/jishu/";?>" <?php if(!empty($gdocfile)) echo "checked";?>> 上传到技术文件夹 </td></tr> <tr align="center"><td> <input type="file" name="attachfile" size=30> <input type="button" name="cmdup" value="提 交" class="ipsub" onclick="javascript:sendform();"> </td></tr></table> </center> </form> </body> </html> --------------------------------------------------------------- 以下摘自php手册 上传表单: <form enctype="multipart/form-data" action="_url_" method="post"> <input type="hidden" name="max_file_size" value="1000"> send this file: <input name="userfile" type="file"> <input type="submit" value="send file"> </form> 我们推荐您使用 $_files。…… 以上范例中 $_files 数组的内容如下所示。我们假设文件上传字段的名称如上例所示,为 userfile。 $_files['userfile']['name'] 客户端机器文件的原名称。 $_files['userfile']['type'] 文件的 mime 类型,需要浏览器提供该信息的支持,例如“image/gif”。 $_files['userfile']['size'] 已上传文件的大小,单位为字节。 $_files['userfile']['tmp_name'] 文件被上传后在服务端储存的临时文件名。 $_files['userfile']['error'] 可以用$uploadfile_name\$uploadfile_type等等来解决,upload代表上传文件,例如问题中的:pic 编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部] 上一篇:有没有很好方法,获得在线登陆用户名单 下一篇:请问textarea表单提交的段落怎样显示分段,急! 转载请注明来源:www.iyit.net 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 相关文章 | ||||
| 友情链接 | ||||||
| 设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接 |
| |||||||