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;
#2

[eluser]TheFuzzy0ne[/eluser]
I'm just as confused as you are. Have you checked to see if either of the images are being put into the ./images directory?
#3

[eluser]masipung[/eluser]
i have checked, but nothing.
i have tried tweaking the code, and if i'm remove several code below, the program can running well, but it's cannot storing filename of image that i have uploaded to database.

>$image = $this->upload- >data();
> if ($image[‘file_ name’])
> {
> $data[‘image’ ] = “.\images\”.$ image[‘file_ name’];
> }


> $thumb = $this->upload- >data();
> if ($thumb[‘file_ name’])
> {
> $data[‘thumbnail’ ] = “/images/”.$ thumb[‘file_ name’];
> }
> $this->db->insert_ string(‘products ‘, $data);


does anyone can help me? or for the member in this forum who success create application like me, can you share (just, how to upload image/video and storing the filename in the database)?


once again, sorry my english isn't good.
#4

[eluser]winter[/eluser]
Off the top of my head:

When seeing blank pages and no errors, it usually means to me that something is not loading. For example, if your DB library for say MSSQL is not installed, CI won't give an error, it will just give a blank page. So there might be a problem with PHP on your server. For example, it might not have some feature compiled in or might not have the correct extension/driver/module installed. OS handle this differently. So I can't get to specific.

Cheers
#5

[eluser]masipung[/eluser]
FYI, I'm using OS windows and xampp 1.6.

maybe, can you give me simple some code "uploading files and storing filename to database" that ever u maked, i will try to my server, if the code as same as i have. it should be a problem in my server (php or OS).


*still learning english
#6

[eluser]winter[/eluser]
Just a quick thought: might the spaces after the underscores be a problem? "_ " Spaces are generally a bad thing to have in names and descriptors. Also, use the code button when posting code. It makes it readable. I might read your code if it was neat.

I haven't used that upload library. So I don't think I know what's wrong with that.




Theme © iAndrew 2016 - Forum software by © MyBB