开发者

How do I upload a simple swf for flash game site?

Swf and I want to upload a picture file. Codes are as follows. What is the problem?

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"]);

      }
    }

My Form:

    <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>

My errors=

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\ta开发者_开发百科sarim\admpanel\yeni.php:6) in C:\AppServ\www\tasarim\admpanel\yeni.php on line 77


So what's the problem?

First of all, if only one of files will have error, then your script will proceed and end up with failure. So you should change and to or in first line.

Furthermore, $_FILES["filename"]["name"] has no slash in front of it, so your file_exists("../resimler" . $_FILES["o_img"]["name"]) will always return false.

Then you should check that destination directory is writable for your script - use is_writable() function.

Then check you web server configuration to know what is the largest file allowed to be uploaded. For PHP look in php.ini for something similar to:

upload_max_filesize = 16M
post_max_size = 18M
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜