简体   繁体   中英

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.

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:

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.

I've modified the following within php.ini (and restarted IIS after each):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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