简体   繁体   English

来自表单发布的图像未上传PHP

[英]Images from form post are not being uploaded PHP

Trying to use form post with images for the first time and I'm getting stuck. 第一次尝试使用带有图像的表单发布,我被卡住了。 The issue is the images are not making there way to the upload directory after submitting the form. 问题在于,提交表单后,图像无法进入上传目录。

Dev Environment I'm currently running this with localhost on my windows 8 home edition laptop using IIS & PHP. 开发环境我目前正在使用IIS和PHP在Windows 8家用版笔记本电脑上使用localhost运行它。

Basically I have my form below ( please note this is a cut down version ): 基本上我下面有我的表格( 请注意,这是一个简化的版本 ):

<form name="myform" action="includes/processpost.php" method="post" enctype="multipart/form-data">
<input id='id_pic' name="upfile1[]" type="file" tabindex="1" multiple accept='image/*' />
<button type="submit" tabindex='2' id="submit_button" >Post</button>

Then (using the magic that is google) I've found that I should be able to access the image uploads through using: 然后,(使用google的魔力)我发现我应该能够通过以下方式访问上传的图片:

function confirm_images_valid(){
    $files=array();
    $fdata=$_FILES['upfile1'];
    for($i=0;$i<count($fdata['name']);++$i){
        $files[]=array(
         'name'    =>$fdata['name'][$i],
         'type'  => $fdata['type'][$i],
         'tmp_name'=>$fdata['tmp_name'][$i],
         'error' => $fdata['error'][$i], 
         'size'  => $fdata['size'][$i]  
        );
    }

    echo 'leaving';
    foreach ($files as $file) {
        $name = $file['name'];
        $tmp = $file['tmp_name'];
        $des = 'C:\Users\D\Desktop\test\\' . $name;

        if (@move_uploaded_file($tmp, $des)) {
            echo 'working';
        }
        else
        { echo 'bugger';}
    }
}

I have also set security on upload_testing folder for 'everyone' to have full privileges, but still I haven't got any files in this folder. 我还对上载“所有人”的upload_testing文件夹设置了安全性,以拥有全部特权,但是仍然没有在此文件夹中保存任何文件。

I've modified the following within php.ini (and restarted IIS after each): 我已经在php.ini中修改了以下内容(并在每个之后重新启动了IIS):

upload_tmp_dir='C:\upload_testing'
upload_max_filesize=20M
max_execution_time=600

Looking for some advice now rather than reading small extracts of how to's and changing more settings! 现在寻找一些建议,而不是阅读有关操作方法的小摘录和更改更多设置!

Thank you in advance 先感谢您

Probably the user executing the webserver has no privileges to write to your User directory. 执行Web服务器的用户可能没有权限写入您的User目录。 Do you check your temp folder? 您是否检查您的临时文件夹? Probably you don't even have the right to put something there. 可能您甚至无权在此放置某些东西。 Do those directories exist? 这些目录是否存在? Those are my most common mistakes. 这些是我最常见的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM