Problem with fileupload in MVC Structure.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Problem with fileupload in MVC Structure.

Post by manojsemwal1 »

hi i have a problem with fileupload iam using the following code to upload the file. that is userdefine mvc structure. i have checked the all those thing simple file upload script is working but when i call the views that time file is not moving the folder.

Pl Help...................

Code: Select all

<?php
Class diesController Extends baseController {



public function Adminarea()
{
       $this->registry->template->blog_heading = 'This is the blog Index';
        $this->registry->template->show('dies');
}

public function insert()
{
$db = new person();
$filename=$_FILES["file"]["name"];
$random_digit=rand(0000,9999);
$newname = 'upload/'.$random_digit.$filename;
$path = 'upload/'.$random_digit.$filename;
//$tmp=$_FILES["file"]["tmp_name"];
$newpath= move_uploaded_file($_FILES["file"]["tmp_name"],$path);
echo $newpath;

 $handle = fopen ("./$path", 'r');



         $rs=$db->uploaddata($handle);
		  if(!$rs)
		  {
		  	 $this->registry->template->blog_heading = 'Pl try Again.........';
		  	 $this->registry->template->show('showmessage');
		  }
		  else
		  {
		  	  $this->registry->template->blog_heading = 'Record Inserted Successfully';
		  	  $this->registry->template->show('showmessage');
		  }

}


}
Thanks
Last edited by Benjamin on Wed Feb 02, 2011 1:16 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Problem with fileupload in MVC Structure.

Post by Jade »

Check to make sure you still the correct path and the folder you're moving the file to has the correct permissions.
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: Problem with fileupload in MVC Structure.

Post by manojsemwal1 »

thanks

I have solved the problem this is due to wrong folder placement...........

but when i have upload the csv file on database some records are not inserted into database due to datatype problem so how can i know that which data has missed to upload............

Pl help.
thanks for your reply..........
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Problem with fileupload in MVC Structure.

Post by Jade »

It probably has to do with your database's character set or the type of field you're uploading the data to ie. maybe its being truncated.
Post Reply