Thursday, February 24, 2011

Re: file upload with miles johnsons upload plugin - without model

Your form is posting to a completely different url. Try setting this:

echo $form->create('Model', array('type' => 'file', 'url' =>
array('controller'=>'pages','action'=>'display', 'upload')));

On Feb 24, 9:05 am, soymartinus <mschenk....@gmail.com> wrote:
> Hi
> i'm new to cakephp and can't get miles johnsons upload plugin (http://www.milesj.me/resources/script/uploader-plugin) to work.
>
> i don't use/need a database for the upload form.
> so i created the upload.ctp in app/views/pages
>
> echo $form->create('Model', array('type' => 'file'));
> echo $form->input('fileName', array('type' => 'file'));
> echo $form->end('Upload');
>
> and added to the pages_controller the
> function upload() like explained in the tutorial on miles webpage.
>
> in routes.php i put
> Router::connect('/upload',
> array('controller'=>'pages','action'=>'display', 'upload'));
>
> thats what i added to the pages_controller:
>
> //uploader plugin
> var $components = array('Uploader.Uploader');
> var $actsAs = array('Uploader.FileValidation');
>
> function upload() {
>         //http://www.milesj.me/resources/script/uploader-plugin
>         $this->set('testvar', "hello world");
>         $this->Uploader->uploadDir = 'files/uploads/';
>         $this->Uploader->enableUpload = true;
>         $this->Uploader->maxFileSize = '8M'; // 8 Megabytes
>         $this->Uploader->maxNameLength = 40;
>         //$this->Uploader->mime('image', 'gif', 'image/gif');
>         //$this->Uploader->delete('files/uploads/filename.jpg');
>
>         if (!empty($this->data)) {
>                 if ($data = $this->Uploader->upload('fileName', array('overwrite' =>
> true, 'name' => 'new_fileName'))){
>                         debug($data);
>                 }
>         }
>
> }
>
> when i now want to upload a file, i get always the error:
> Error: ModelsController could not be found.
>
> thank you very much in advance for any help
>
> regards from spain, martin

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: