Welcome Guest, Not a member yet? Register   Sign In
Need help uploading file and get the file name to store in database mysql...URGENT
#1

[eluser]masipung[/eluser]
Sorry my english isn't good enough.
i have created the application that contain upload file. But, after i run that program. That program could,t upload file. That make me more confuse, nothing error or warning message that appear in browser. Just show the blank page after i clik submit button.
Does anyone can help??

Here is the code:
>MProducts ( Model )
> function addProduct()
> {
> $data = array(
> 'id'=>'',
> 'name' => $_POST['name' ],
> 'shortdesc' => $_POST['shortdesc' ],
> 'longdesc' => $_POST['longdesc' ],
> 'status' => $_POST['status' ],
> 'grouping' => $_POST['grouping' ],
> 'category_id' => $_POST['category_ id'],
> 'featured' => $_POST['featured' ],
> 'price' => $_POST['price' ]
> );
>
> $config['upload_ path'] = '.\images';
> $config['allowed_ types'] = 'gif|jpg|png' ;
> $config['max_ size'] = '200';
> $config['remove_ spaces'] = true;
> $config['overwrite' ] = false;
> $config['max_ width'] = '0';
> $config['max_ height'] = '0';
> $this->load- >library( 'upload', $config);
>
> if(!$this->upload- >do_upload( 'image'))
> {
> $this->upload- >display_ errors();
> exit();
> }
>
> $image = $this->upload- >data();
> if ($image['file_ name'])
> {
> $data['image' ] = ".\images\".$ image['file_ name'];
> }
>
> if(!$this->upload- >do_upload( 'thumbnail' ))
> {
> $this->upload- >display_ errors();
> exit();
> }
>
> $thumb = $this->upload- >data();
> if ($thumb['file_ name'])
> {
> $data['thumbnail' ] = "/images/".$ thumb['file_ name'];
> }
> $this->db->insert_ string('products ', $data);
>
> }
>

> Products (controller)
> function create()
> {
> if($this->input- >post('name' ))
> {
> $this->MProducts- >addProduct( );
> $this->session- >set_flashdata( 'message' ,'Product created');
> redirect('admin/ products/ index','refresh' );
> }else{
> $data['title' ]="Create Products";
> $data['main' ] = 'admin_product_ create';
> $data['categories' ] = $this->Mcat- >getCategoriesDr opDown();
> $this->load- >vars($data) ;
> $this->load- >view('dashboard ');
> }
> }
>
> admin_product_ create ( view )
>
> &lt;title&gt;&lt;h1>< ?php echo $title; ?&gt;</h1>&lt;/title&gt; &lt;/head&gt;
>
> &lt;body&gt;&lt;?php
> echo $_POST['name' ];
> echo form_open_multipart ('admin/products /create') ;
>
> echo "<p><label for='parent' >Category< /label><br/ >";
> echo form_dropdown( 'category_ id',$categories) ."</p>";
>
> echo "<p><label for='pname'> Name</label> <br/>";
> $data = array('name' =>'name', 'id'=>'pname' ,'size'=> 25);
> echo form_input($ data) ."</p>";
>
> echo "<p><label for='short'> Short Description< /label><br/ > ";
> $data = array('name' =>'shortdesc' ,'id'=>'short' ,'size'=> 40);
> echo form_input($ data) ."</p> ";
>
> echo "<p><label for='long'> Long Description< /label><br/ > ";
> $data = array('name' =>'longdesc' ,'id'=>'long' ,'rows'=> 5, 'cols'=>'40' );
> echo form_textarea( $data) ."</p> ";
>
> echo "<p><label for='uimage' > Upload Image</label> <br/> ";
> $data = array('name' =>'image' ,'id'=>'uimage' );
> echo form_upload( $data) ."</p> ";
>
> echo "<p><label for='uthumb' > Upload Thumbnail</label> <br/> ";
> $data = array('name' =>'thumbnail' ,'id'=>'uthumb' );
>
> echo form_upload( $data) ."</p> ";
> echo "<p><label for='status' > Status</label> <br/> ";
> $options = array('active' =>'active' , 'inactive'=> 'inactive' );
>
> echo form_dropdown( 'status', $options) ."</p> ";
> echo "<p><label for='group'> Grouping</label> <br/> ";
> $data = array('name' =>'grouping' ,'id'=>'group' ,'size'=> 10);
>
> echo form_input($ data) ."</p> ";
> echo "<p><label for='price'> Price</label> <br/> ";
> $data = array('name' =>'price' ,'id'=>'price' ,'size'=> 10);
>
> echo form_input($ data) ."</p> ";
> echo "<p><label for='featured' > Featured?</label> <br/> ";
> $options = array('true' =>'true', 'false'=>'false' );
>
> echo form_dropdown( 'featured' ,$options) ."</p> ";
> echo form_submit( 'submit', 'create product');
> echo form_close() ;
> ?&gt;


Messages In This Thread
Need help uploading file and get the file name to store in database mysql...URGENT - by El Forum - 02-24-2009, 08:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB