CodeIgniter Forums

Full Version: Send image to other method
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I get the finished data from a form via POST in one method and want to pass the image to another method for file upload. How should I pass $ _FILES ['my_image'] from one method to another?
$_FILES['my_image'] is not the image itself, it's an associative array containing information about the uploaded file.
It looks something like this:
[name] => image.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php3zX7t5
[error] => 0
[size] => 25974
(08-29-2019, 08:33 PM)adamoli Wrote: [ -> ]$_FILES['my_image'] is not the image itself, it's an associative array containing information about the uploaded file.
It looks something like this:
[name] => image.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php3zX7t5
[error] => 0
[size] => 25974


Yes, it is a array. But I'm assigning this array to a variable and sending it to another method of the same class. Then I pass this variable to the CodeIgniter upload class $this->upload->do_upload($my_image['tmp_name']), but returns an error saying no images were uploaded!
That's because the upload is looking for the image to be in a folder.

You should save the image to a folder then upload it from there.