0

HTML code is below

Upload Your pic only in jpg (Less 1 MB)

    <input type="file" title="Upload Your pic in jpg (Less 1 MB)" accept="image/jpeg" required="" class="select-style" tabindex="1" name="file[]"  multiple />

PHP code is below:

echo $_POST[$_FILES['file[]']];
echo $_POST[$_FILES["file"]["size"]];
4
  • Use $_FILES[] without the post array. Commented Oct 1, 2013 at 9:00
  • I am sending data from html page to Php page it did not handle if I use only $_FILES[]. Commented Oct 1, 2013 at 9:03
  • php.net/manual/en/features.file-upload.post-method.php Commented Oct 1, 2013 at 9:05
  • What does handle mean? Commented Oct 1, 2013 at 9:21

4 Answers 4

1

Your fomr must contain

enctype="multipart/form-data"

Like :-

<form name="upload" id="upload" method="post" action="" enctype="multipart/form-data">
Sign up to request clarification or add additional context in comments.

1 Comment

I also use enctype="multipart/form-data" it. Kindly understand my question, I have two pages one is html and second is php Now I send upload file and want to use on php page
0

You can use $_FILES['file']['size'][0]; to get size of uploaded file

Hope this will help you

Thanks

1 Comment

Kindly understand my question, I have two pages one is html and second is php Now I send upload file and want to use on php page
0

Ok..

here is my HTML Page page name stack.html

<form name="upload" id="upload" method="post" action="stack.php" enctype="multipart/form-data">
     <input type="file" title="Upload Your pic in jpg (Less 1 MB)" accept="image/jpeg" required="" class="select-style" tabindex="1" name="file[]"  multiple />



     <input type="submit" value="submit">
</form> 

and here my PHP page page name stack.php

<?php

if(!empty($_FILES)){
    echo "<pre>";
    print_r($_FILES);
    echo "</pre>";
    exit;
}

?>

Comments

0

See if it gives any luck. Try it in php file..

foreach($_FILES as $file){
    print_r($file['size']);
    print_r($file['name']);
    //if you want total size of all images
    echo array_sum($file['size']);
    //if you want individual name
    for($i=0;$i<count($file['name']);$i++){
        echo $file['name'][$i];
        echo $file['size'][$i];
    }

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.