Note that there are some explanatory texts on larger screens.

plurals
  1. POfile upload path into database in codeigniter
    primarykey
    data
    text
    <p>Hi Every One,<br> I'm trying to upload the file path in data base but it is redirecting same and file is not uploading can any one help me .. This is My Controller.</p> <pre><code>&lt;?php if (!defined ('BASEPATH'))exit('no direct scripts allowed '); class Main extends CI_Controller { function __construct () { parent::__construct(); $this-&gt;load-&gt;library('session'); } function insert_quiz_data() { $this-&gt;load-&gt;library('form_validation'); //loading validation library $this-&gt;form_validation-&gt;set_rules('qtitle','quiz_title'); //setting rules for validation $this-&gt;form_validation-&gt;set_rules('qcategory1','quiz_category1'); $this-&gt;form_validation-&gt;set_rules('qcategory2','quiz_category2'); $this-&gt;form_validation-&gt;set_rules('qcategory3','quiz_category3'); $this-&gt;form_validation-&gt;set_rules('astatus','email'); $this-&gt;form_validation-&gt;set_rules('userfile', 'quiz_image_path', 'callback__do_upload'); //userfile is the upload file field name in form , echo 'testing'; if($this-&gt;form_validation-&gt;run()!=false) { //Get the info from the form $username = $this-&gt;input-&gt;post('qtitle'); $password = $this-&gt;input-&gt;post('qcategory1'); $passconf = $this-&gt;input-&gt;post('qcategory2'); $date = $this-&gt;input-&gt;post('qcategory3'); $email = $this-&gt;input-&gt;post('astatus'); $temp=$this-&gt;upload-&gt;data(); $image=$temp['file_name'];// to get image file name rom upload script , as it could be stored in the databae //load the model $this-&gt;load-&gt;model('quiz_mode'); //execute the registration query $data = $this-&gt;quiz_mode-&gt;register_user($username,$password,$passconf,$date,$image,$email); //if $data == TRUE if($data) { echo "you have successfully made your registration"; $this-&gt;load-&gt;view('logged_in_area'); } else { echo "faillled"; } } else{ //You arrived here just in case the form fields are not correct $this-&gt;load-&gt;view('logged_in_area'); //loading reg form here } } public function _do_upload() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $field_name = 'userfile'; $this-&gt;load-&gt;library('upload', $config); if ( ! $this-&gt;upload-&gt;do_upload($field_name)) { $this-&gt;form_validation-&gt;set_message('_do_upload', $this-&gt;upload-&gt;display_errors()); return FALSE; } else { $image_data = $this-&gt;upload-&gt;data(); $filename = $image_data['file_name']; $config = array ( 'source_image' =&gt; $image_data['full_path'], 'new_image' =&gt; './uploads/thumbs/', 'maintain_ratio' =&gt; false, 'width' =&gt; 300, 'height' =&gt; 200 ); $this-&gt;load-&gt;library('image_lib', $config); $this-&gt;image_lib-&gt;resize(); return TRUE; } } } </code></pre> <p>My Model Class:</p> <pre><code>&lt;?php class File_model extends CI_Model { function File_model() { parent::__construct(); } function register_user($username,$password,$passconf,$date,$image,$email) { $data= array('username'=&gt;$username, 'password'=&gt;$password, 'passconf'=&gt;$passconf, 'date'=&gt;$date, 'image'=&gt;$image, 'email'=&gt;$email ); $res= $this-&gt;db-&gt;insert('register', $data); //register is my table name return $res; var_dump($res); } } ?&gt; </code></pre> <p>My View</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;?php $this-&gt;load-&gt;helper('form'); ?&gt; &lt;?php echo form_open_multipart('index.php/main'); ?&gt; &lt;?php echo validation_errors(); ?&gt; &lt;table width="348" align="center" cellpadding="0" cellspacing="0"&gt; &lt;tr&gt; &lt;td colspan="2" align="center"&gt;&lt;h2&gt;&lt;strong&gt;REGISTERATION AREA&lt;/strong&gt;&lt;/h2&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;?php //echo validation_errors(); ?&gt; &lt;td width="97" height="40"&gt;&lt;label for"username"&gt; &lt;strong&gt;Username &lt;/strong&gt;&lt;/label&gt;&lt;/td&gt; &lt;td width="249"&gt;&lt;input type="text" id="username" name="username" value="&lt;?php echo set_value('username'); ?&gt;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for"password"&gt; &lt;strong&gt;Password &lt;/strong&gt;&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="password" name="password" id="password" value="&lt;?php echo set_value('password'); ?&gt;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for"confirm password"&gt; &lt;strong&gt;Passconf&lt;/strong&gt;&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="password" name="passconf" id="passconf" value="&lt;?php echo set_value('passconf'); ?&gt;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for"date "&gt;&lt;strong&gt;Date&lt;/strong&gt;&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="datepicker" id="datepicker" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;strong&gt;Upload Picture&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="file" name="userfile" size="20" id="userfile" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for"email"&gt; &lt;strong&gt;Email&lt;/strong&gt;&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td height="44"&gt;&amp;nbsp;&lt;/td&gt; &lt;td align="center"&gt; &lt;input type="submit" id="submit" value="Register" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Can anyone help me . Thanks.</p>
    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.
 

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