dqwmhrxt68679 2013-05-01 11:54
浏览 17
已采纳

在PHP文件上传期间检查帖子属性[关闭]

Hi I have the following saved as upload.php.

<html>
<head>
</head>
<body>
    <?php
        for($file_count = 0; $file_count <= count($_FILES['files']['tmp_name']); $file_count++){
            echo '111111';
            if( $_FILES['files']['error'][$file_count] == 0){
                echo '2222222222';
                $target_dir = "uploads/".time().$_FILES['files']['name'][$file_count];
                echo '333333333333';
                move_uploaded_file($_FILES['files']['tmp_name'][$file_count], $target_dir);
                echo '4444444444444';
            }
        }
    ?>
    <div>
        <form method="post" name="upload_form" enctype="multipart/form-data"
            action="">
            <input type="file" name="files[]" enctype="form/multipart"> <input
                type="submit" id="photo_upload" value="Upload Photo...">
        </form>
        <div id="contents">fggfgfg</div>

    </div>
</body>
</html>

The upload works fine. The problem is when I launch the page, I see error messages. (Can't upload screenshots to show them).

To avoid them I tried checking if the form was set in the post request like so: if(isset($_POST[])).

But when I have the above if block, the code inside it does'nt get executed even when I select and submit the files.

How can I get around this.

QUESTION 2:

Can somebody please point me to jquery based file upload example? I have to asynchrously upload files since there are other form field available on the page.

  • 写回答

2条回答 默认 最新

  • douqian5553 2013-05-01 11:57
    关注

    You should give name attribute to your submit element change it to this

    <input type="submit" id="photo_upload" name="Submit" value="Upload Photo...">
    

    and then check like this

    if(isset($_POST['Submit']))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?