CodeIgniter Forums
Send image to other method - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Send image to other method (/thread-74226.html)



Send image to other method - Henqsan - 08-29-2019

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?


RE: Send image to other method - adamoli - 08-29-2019

$_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


RE: Send image to other method - Henqsan - 08-30-2019

(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!


RE: Send image to other method - InsiteFX - 08-30-2019

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.