Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthoreuricovidal
     
    I'm trying to send file (. Jpg)
    but I can not ...
    I would like someone to explain in detail how that makes "upload file"?

    thanks
      Captura_de_tela.png
    • CommentAuthorpogeybait4883
     

    Forget the helpers

    create a form upload element on your form

    <form enctype="multipart/form-data">
        <input type="file" name="myfile" id="myfile" />
    </form>
    

    in your controller do this:

    if( $this->Request->isPost() ) { //see if a form has posted.
        //echo '<pre>' . print_r($_FILES, 1) . '</pre>'; exit(); //uncomment this line to have a look at the $_FILES array
        if( file_exists( $_FILES['myfile']['tmp_name'] ) ) {  //check to make sure the file exists.
            move_uploaded_file( $_FILES['myfile']['tmp_name'], $uploads_dir.'/'.$_FILES['myfile']['name'] );  //do something with the file
        }
    }
    

    Just an added note. On unix systems checked your php.ini to see where the tmp directory is. Most systems specify /tmp . Make sure it is writable by everyone (i.e. chmod 777 /tmp )

    -- Pogeybait