Note that there are some explanatory texts on larger screens.

plurals
  1. POimage upload into subfolder in codeigniter
    primarykey
    data
    text
    <p>i'm new to codeigniter..please help me in uploading image in codeigniter.first i need to create a sub folder inside "codeigniter/userimage/" with the user id as folder name. i did that.this is my controller function</p> <pre><code>function update(){ $uppath="/var/www/html/codeigniter/userimage/"; $sess_id= $this-&gt;session-&gt;userdata('userid'); $folder=$uppath.$sess_id; if(!is_dir($folder)) mkdir ($folder,777); if($x&gt;0){ $config['upload_path']='./userimage/'.$folder.'/'; $config['allowed_types'] = 'gif|jpg|png|jpeg'; $config['max_size'] = '9000'; $config['max_width'] = '1024'; $config['max_height'] = '1000'; echo 'haii'; $this-&gt;load-&gt;library('upload'); $this-&gt;upload-&gt;initialize($config); echo 'heloooo'; if (!$this-&gt;upload-&gt;do_upload('picfile')) { print_r( $this-&gt;upload-&gt;display_error() );die; } else { $image=$this-&gt;upload-&gt;do_upload('picfile'); // echo 'uploaded'; echo $image; } } } </code></pre> <p>i'm calling my method update written inside the model 'home' from the view 'profileinfo'.</p> <p>my view profileinfo is:</p> <pre><code>`&lt;?php $fn=''; $ln=''; $un=''; $em=''; $b=''; $gr=''; foreach ($query as $row){ $fn=$row-&gt;firstname; $ln=$row-&gt;lastname; $un=$row-&gt;username; $em=$row-&gt;email; $b=$row-&gt;bday; $gr=$row-&gt;gender; } ?&gt; &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;h1&gt;&lt;u&gt;My Profile Details&lt;/u&gt;&lt;/h1&gt; &lt;br&gt;&lt;br&gt;&lt;div id="viewdiv" align="center"&gt; &lt;div align="right" style="font-weight: bold;font-size: 20px;"&gt; &lt;a href="home"&gt;Back&lt;/a&gt;&lt;/div&gt; &lt;?php echo form_open_multipart('home/update');?&gt; &lt;br&gt; &lt;table border="0" align="center"&gt; &lt;tr class='spacerow'&gt; &lt;td&gt; &lt;h2&gt; Name:&lt;/h2&gt; &lt;/td&gt; &lt;td&gt;&lt;?php echo"&lt;input type='text' name='first' value='$fn'&gt;";?&gt; &lt;?php echo"&lt;input type='text' name='last' value='$ln'&gt;";?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class='spacerow'&gt; &lt;td&gt; &lt;h2&gt; User Name:&lt;/h2&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo"&lt;input type='text' name='uname' value='$un'&gt;";?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class='spacerow'&gt; &lt;td&gt; &lt;h2&gt; Date of birth:&lt;/h2&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo"&lt;input type='text' name='dobb' id='datepicker' value='$b'&gt;";?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class='spacerow'&gt; &lt;td&gt; &lt;h2&gt; Gender: &lt;/h2&gt; &lt;/td&gt; &lt;?php if($gr=="male"){ ?&gt; &lt;td&gt; &lt;?php echo"&lt;h3&gt;Male:&lt;input type='radio' name='gen' value='male' checked&gt;";?&gt; &lt;?php echo"Female:&lt;input type='radio' name='gen' value='female' &gt;&lt;/h3&gt;";?&gt; &lt;/td&gt; &lt;?php } else{ ?&gt; &lt;td&gt; &lt;?php echo"&lt;h3&gt;Male:&lt;input type='radio' name='gen' value='male'&gt;";?&gt; &lt;?php echo"Female:&lt;input type='radio' name='gen' value='female' checked&gt;&lt;/h3&gt;";?&gt; &lt;/td&gt; &lt;?php } ?&gt; &lt;/tr&gt; &lt;tr class='spacerow'&gt; &lt;td&gt; &lt;h2&gt; Email:&lt;/h2&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo"&lt;input type='text' name='mail' value='$em'&gt;";?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class='spacerow'&gt; &lt;td&gt; &lt;h2&gt; Profile Picture:&lt;/h2&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="file" name="picfile"&gt; &lt;p&gt;if you want to change your profile picture,browse here..&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;br&gt; &lt;center&gt; &lt;input type="submit" name="update" value="update"&gt;&lt;/center&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p> ` the sub folder "$folder" is creating inside userimage and i want to store the uploaded image into that sub folder.my problem is the image is not uploading. you can see i put two echo statement before and after loading upload library. but i'm getting only the output "haii".. i dont get any idea about what is the problem..please anybody help me.. thanks..</p>
    singulars
    1. This table or related slice is empty.
    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