【问题标题】:How do I upload a simple swf for flash game site?如何为 Flash 游戏网站上传简单的 swf?
【发布时间】:2011-07-07 18:28:50
【问题描述】:

Swf 和我想上传一个图片文件。代码如下。有什么问题?

if ($_FILES["o_img"]["error"] > 0 and $_FILES["o_swf"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["o_img"]["error"] . "<br />";
    echo "Return Code: " . $_FILES["o_swf"]["error"] . "<br />";
    }
    else
    {
    if (file_exists("../resimler" . $_FILES["o_img"]["name"]) and file_exists("../swf" . $_FILES["o_swf"]["name"]))
      {
      echo $_FILES["o_img"]["name"] . "bu isimde bir resim daha önce yüklenmiş ";
      echo $_FILES["o_swf"]["name"] . "bu isimde bir resim daha önce yüklenmiş ";
      }
    else
      {
      move_uploaded_file($_FILES["o_img"]["tmp_name"],
      "upload/" . $_FILES["o_img"]["name"]);
       move_uploaded_file($_FILES["o_swf"]["tmp_name"],
      "upload/" . $_FILES["o_swf"]["name"]);

      }
    }

我的表格:

    <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
      <p>
         <input type="text" name="o_baslik" id="o_baslik" />
:        Oyun İsmi</p>
      <p><br />
  <input type="text" name="o_etiketler" id="o_etiketler" />
        :
        Oyunun Etiketleri</p>
      <p><br />
        <input type="file" name="o_img" id="o_img" />
        :Oyun Resmi        </p>
      <p><br />
        <input type="file" name="o_swf" id="o_swf" />
        SWF Dosyası<br />
      </p>
      <input type="submit"/>
    </form>

我的错误=

Warning: move_uploaded_file(upload/71IwNCX6PhL__SL1500_.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\AppServ\www\tasarim\admpanel\yeni.php on line 65

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\phpD014.tmp' to 'upload/71IwNCX6PhL__SL1500_.jpg' in C:\AppServ\www\tasarim\admpanel\yeni.php on line 65

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\tasarim\admpanel\yeni.php:6) in C:\AppServ\www\tasarim\admpanel\yeni.php on line 77

【问题讨论】:

  • NOT诸如“代码”之类的词!
  • 检查脚本是否对该文件夹有写权限。此外,您的脚本存在安全漏洞。如果我上传一个 PHP 文件怎么办?
  • @daGrevis 有“codes”这样的词(但在这篇文章中确实被误用了),而“There are NOT such word as 'codes'”这句话本身至少有两个语法错误。

标签: php upload flash


【解决方案1】:

那么问题出在哪里?

首先,如果只有一个文件有错误,那么您的脚本将继续执行并以失败告终。所以你应该在第一行把and改成or

此外,$_FILES["filename"]["name"] 前面没有斜线,因此您的 file_exists("../resimler" . $_FILES["o_img"]["name"]) 将始终返回 false

然后您应该检查目标目录对于您的脚本是否可写 - 使用 is_writable() 函数。

然后检查您的网络服务器配置以了解允许上传的最大文件。对于 PHP,请在 php.ini 中查找类似于以下内容的内容:

upload_max_filesize = 16M
post_max_size = 18M

【讨论】:

  • errors = 警告:move_uploaded_file(upload/71IwNCX6PhL__SL1500_.jpg) [function.move-uploaded-file]:无法打开流:C:\AppServ\www\tasarim\ 中没有这样的文件或目录第 65 行上的 admpanel\yeni.php 警告:move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\phpD014.tmp' to 'upload/71IwNCX6PhL__SL1500_.jpg' in C:\ AppServ\www\tasarim\admpanel\yeni.php 第 65 行警告:无法修改标头信息 - 标头已由 C:\ AppServ\www\tasarim\admpanel\yeni.php 在第 77 行
  • 您有一个明确的错误:找不到您尝试移动上传文件的目录。发生这种情况是因为您的脚本所在的目录中没有 upload 目录。提供 dir 的绝对路径总是更好。在您的情况下,它应该类似于:move_uploaded_file("C:\AppServ\www\tasarim\upload\" . $filename)
  • 和@Yusuf 确保这个目录确实存在。
猜你喜欢
  • 2012-06-04
  • 2012-09-17
  • 1970-01-01
  • 1970-01-01
  • 2018-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多