Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck did select file Or no, in input:file
    primarykey
    data
    text
    <p>How can know, if select(<code>Choice</code> Or <code>Browse...</code>) file in <code>input:file</code> run some code with php?</p> <pre><code>&lt;form action="#" method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="userfile[]" valign="baseline"&gt; &lt;/form&gt; if(select file){ run my code } </code></pre> <p><strong>Update:</strong></p> <p>I use of <a href="http://www.mitesdesign.com/blog/open-source/multi-upload-jquery-code-igniter" rel="nofollow">Multiple Uploads with JQuery and Code Igniter</a> , when that i don't select file, output <code>print_r($_FILES['userfile']);</code> is: </p> <blockquote> <p>Array ( [error] => 4 [name] => [size] => 0 [tmp_name] => [type] => [key] => userfile )</p> </blockquote> <p><code>[error] =&gt; 4</code> is -> You did not select a file to upload.</p> <p>If i select file, have following error in case i have in <code>input:file</code> this: <code>name="userfile[]"</code>:</p> <p><code>Message: Undefined index: userfile</code> in here:<code>print_r($_FILES['userfile']);</code></p> <p><strong>Update 2:</strong> I use from these Controller but if don't select a file, in the here <code>if ( ! $files )</code> return is false and give error. i want if user did not select file does not get error with a if</p> <pre><code>class Upload extends Controller { function Upload() { parent::Controller(); $this-&gt;load-&gt;helper(array('form', 'url')); } function index() { $this-&gt;load-&gt;view('upload_form'); } function do_upload() { if($_FILE('userfile')){ $config['upload_path'] = './uploads/'; // server directory $config['allowed_types'] = 'gif|jpg|png'; // by extension, will check for whether it is an image $config['max_size'] = '1000'; // in kb $config['max_width'] = '1024'; $config['max_height'] = '768'; $this-&gt;load-&gt;library('upload', $config); $this-&gt;load-&gt;library('Multi_upload'); $files = $this-&gt;multi_upload-&gt;go_upload(); if ( ! $files ) { $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors()); $this-&gt;load-&gt;view('upload_form', $error); } else { $data = array('upload_data' =&gt; $files); $this-&gt;load-&gt;view('upload_success', $data); } } redirect('inse/show'); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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