2013-08-24 18:52
浏览 48

html表单enctype = multipart / form-data

Hi I'm trying to create a form that will load images following some web examples but I can't get the images to load. I'm working on my personal fedora box running apache. Is there some settings that I have to do differently with Apache? Here's my form script that should be uploading image:

            <form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "get">
                  <th>Title:</th> <td><input type="text" name ="photoname"></td>
               <th>Photograph:</th> <td><input type="file" id="file" name="file" accept="image/*"></td>
               <th>Photographer:</th><td><input type="" name="photographer"></td>
               <th>Genre:</th><td><input type = "" name="genre"></td>
               <input type="submit" value = "Submit">

And Here's my PHP script:

        $uploaddir = '/var/www/html/photodb';
        $uploadfile = $uploaddir . basename($_FILES['file']['name']);

        echo '<pre>';
        if (move_uploaded_file($_FILES['file']['name'], $uploadfile)) {
            echo "File is valid, and was successfully uploaded.
        } else {
            echo "Possible file upload attack!

        echo 'Here is some more debugging info:';

        print "</pre>";

When I add an image through the form the php form fails saying "Possible file upload attack!" I guess this means either the file was not able to be moved or the file was not uploaded?

I'm doing this for my college assignment any response or other idea is dearly appreciated :).

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongyan7876 2013-08-24 18:54

    Change your method to POST:

    <form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "post">

    You cannot post your files via GET method.

    解决 无用
    打赏 举报

相关推荐 更多相似问题