如何为Flash游戏网站上传简单的swf?

时间:2011-07-07 18:28:50

标签: php upload flash

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

1 个答案:

答案 0 :(得分:0)

那么问题是什么?

首先,如果只有一个文件会出错,那么您的脚本将继续运行并最终失败。因此,您应该在第一行中将and更改为or

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

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

然后检查您的Web服务器配置,以了解允许上载的最大文件是什么。对于PHP,请在php.ini中查找类似于:

的内容
upload_max_filesize = 16M
post_max_size = 18M