dongtingrun4973 2010-09-11 07:45
浏览 31
已采纳

PHP - 可以在没有<form>标签的情况下上传吗?

If upload file with php , with simple way , i can do like this page

<?php 
  if($_FILES)
{
   DO UPLOAD 
}
?>
<form action='' enctype='multipart/form-data' method='post'>
  <input type="file" name="file">
  <input type="submit" name="upload" value="submit">
</form>

And now, i have to upload file but with out <form> tag like this

------index.html----
    <input type="file" name="file">
    <a href="upload.php">Upload</a>
--------------------

------upload.php-----
 CODE PHP TO UPLOAD FILE
---------------------

when click upload link , it can be a page that do upload.

But i don't know how to the upload page can get file without tag form

Simple index.html only to send file name , and where it local to upload page proccess

sorry for my bad english

  • 写回答

4条回答 默认 最新

  • dongnuo4594 2010-09-11 08:58
    关注

    It's not quite clear what you want. But there is in fact a way to upload files without forms (and its POST request method/ctype). It's called a "PUT" request. All major http libraries can do that. Major browsers only via AJAX.

    However, the receiving script must have specific support for it. Needs to check $_SERVER[REQUEST_METHOD] and read form php://input, and it really just allowed receiving a single file. It might even be necessary to set it up as Apache handler:

    First Google result: http://www.phpbuilder.com/manual/features.file-upload.put-method.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站