Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should keep your model for database operations only. All the upload processing and file moving has to be done in the controller. The model has to insert the record about the photo in the database and that's about it.</p> <p>And as a response to your question do a <code>print_r($files)</code> and see what it contains. It should have the original filenames. It'll probably be something like artmania said above: <code>$files[0]['file_name']</code>. You should be able to loop through your $files array with a foreach construct like this:</p> <pre><code>foreach($files as $file) { $file_name = $file['file_name']; } </code></pre> <p>You can get all the other data about the file in the same way. The CodeIgniter manual says about <code>$this-&gt;upload-&gt;data()</code>:</p> <blockquote> <p>This is a helper function that returns an array containing all of the data related to the file you uploaded. Here is the array prototype:</p> </blockquote> <pre><code>Array ( [file_name] =&gt; mypic.jpg [file_type] =&gt; image/jpeg [file_path] =&gt; /path/to/your/upload/ [full_path] =&gt; /path/to/your/upload/jpg.jpg [raw_name] =&gt; mypic [orig_name] =&gt; mypic.jpg [file_ext] =&gt; .jpg [file_size] =&gt; 22.2 [is_image] =&gt; 1 [image_width] =&gt; 800 [image_height] =&gt; 600 [image_type] =&gt; jpeg [image_size_str] =&gt; width="800" height="200" ) </code></pre> <p>Fore more info <a href="http://codeigniter.com/user_guide/libraries/file_uploading.html" rel="nofollow noreferrer">check out the manual</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload