-1

I am not able to upload image, I tried using the below code to display. But nothing gets displayed.

PHP Code is as

$question_image = $allquestion["'ques_image'"];<br>
$imagetemp = $_FILES[$question_image]['name'];<br>
echo "IMAGE NAME".$imagetemp;

And Returned Array

Array
(
[1] => Array
    (
        ['ques_title'] => Question 1
        ['ques_image'] => galaxy_s7_black.png
        ['choice'] => Array
            (
                [0] => Array
                    (
                        [0] => Question 1 - First Choice
                        [1] => 127
                    )

                [1] => Array
                    (
                        [0] => Question 1 - second Choice
                        [1] => 128
                    )
            )
    )

[2] => Array
    (
        ['ques_title'] => Question 2
        ['ques_image'] => iphone7_rosegold.png
        ['choice'] => Array
            (
                [0] => Array
                    (
                        [0] => Question 2 - First Choice
                        [1] => 131
                    )

                [1] => Array
                    (
                        [0] => Question 2 - second Choice
                        [1] => 132
                    )
            )
    )
)

How to upload image in a multidimensional array loop.

7
  • ques_image contains image name only of the image file? Commented Jan 4, 2018 at 5:43
  • add the value of print_r( $_FILES) what it will return ? Commented Jan 4, 2018 at 5:47
  • @PrateikDarji name="quiz[1]['ques_image']" this is how I am submitting data. Commented Jan 4, 2018 at 5:48
  • @Narayan , it outputs empty array Commented Jan 4, 2018 at 5:49
  • @topper1309 if it will return empty then, check your form attribute have you added enctype=multipart/form-data ? Commented Jan 4, 2018 at 5:51

1 Answer 1

0

How did you print the array?

You must call the array arguments in step-by-step

for example :

echo $_FILES[1]['ques_image']

or

echo $_FILES[2]['ques_image']
Sign up to request clarification or add additional context in comments.

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.