Re: how getting upload file array only element.array_file to table.db
Because you are not actually uploading a file. Sure you are presenting
an upload form, but it looks like you aren't doing anything with that
upload after the form submission. You should really do the following:
1 - After form submission, validate the file upload and error out if
something is wrong
2 - If valid, upload the file to some location and save the path
3 - Set the path to the data being inserted into the database, not the
filename
4 - Remove the files array from the data as it is no longer needed
I would suggest using an uploader system if you are not already.
http://milesj.me/code/cakephp/uploader
On Nov 19, 6:35 am, Ogalav <omar...@gmail.com> wrote:
> hi, the situation is following
> the add.ctp will save one file of type ".doc"
> all right with description and code type..etc according cakephp`s
> manual 2.0
>
> but when get to save..it said me that fiel [doc] of table ordenes cant
> be "array", en then i make debug in the controller
>
> (
> [Orden] => Array
> (
> [n_orden] => 11111
> [n_admin] => 22222
> [cliente] => dadad
> [obs_orden] => dadada
> [obs_estado] => adada
> [estado] => cerrado
> [user_id] => 1
> [fecha_entrega] => Array
> (
> [month] => 11
> [day] => 19
> [year] => 2011
> )
>
> [doc] => Array
> (
> [name] => 5_gsm_web.pdf
> [type] => application/pdf
> [tmp_name] => /tmp/php0QWesp
> [error] => 0
> [size] => 700784
> )
>
> )
>
> )
>
> **** how i do it.. the controller only take the "[name]" of array
> "doc", because "[name]" will be save into fiel of table
>
> i place also this code for checking according documentation
>
> function isUploadedFile($params){
> $val = array_shift($params);
> if ((isset($val['error']) && $val['error'] == 0) ||
> (!empty( $val['tmp_name']) && $val['tmp_name'] != 'none')
> ) {
> return is_uploaded_file($val['tmp_name']);
> }
> return false;
>
> }
>
> ***** how i do the "check flash" for is to be " .doc" and not other
> type file???
>
> thanks
>
> regards
--
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home