PEAR has one of the easiest uploaders to use:
http://pear.php.net/package/HTTP_Upload
drop the file into your vendors folder, and then follow this:
In your view:
-----------------------------------------------------
<?php echo $html->form('/wherever/', 'POST',
array('enctype'=>'multipart/form-data')); ?>
<input type="file" name="userfile" />
</form>
In your controller:
-----------------------------------------------------
vendors('HTTP_Upload');
$upload = new HTTP_Upload("en");
$file = $upload->getFiles("userfile");
if ($file->isValid()) {
$moved = $file->moveTo("uploads/");
if (!PEAR::isError($moved)) {
$this->flash("File was moved to uploads/", '/wherever/');
exit;
}
}
also google "Pear HTTP_Upload" for a bunch of different tutorials.
rtanz wrote:
> hi i need a simple file upload function, basically the users would be
> filling in a form and have to upload two files in the form. I dont
> need anything fancy just the facility to specify the location of the
> file and then the files get uploaded on submitting the form. When they
> view the form they should see a link to the uploaded file.
>
> is there some built in cake facility to do this or should i be looking
> at other solutions? thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---