Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    •  
      CommentAuthorpeter
     
    Does anyone have a pointer in the right direction on how to get file uploads working? At the moment I don't need image resizing, just simple upload fields for file storage. There probably is no plugin like attachment_fu for Akelos yet?
    •  
      CommentAuthorbermi
     

    Hi Peter,

    Akelos does not have a functionality like the provided by attachment_fu yet. I once ported acts_as_attachment, but found it to cause too much overhead on something that could be handle with a simple convention /files/model_name/id and then deliver them using AkActionController::sendData(); or AkActionController::sendFile();

    Anyhow, I still looking for an elegant solution for Akelos that allows to switch storage in a very simple way. Especially S3, and asset servers.

    In Akelos you can use the old PHP method for file uploading by

    adding something like this in your view:

    <%= start_form_tag {'controller'=>'file', 'action'=>'add'}, {'enctype'=>'multipart/form-data'} %>
    <input id="file" name="file" type="file" />
    <input value="Upload file" type="submit" />
    </form> 
    

    and something like this in your controller:

    function add()
    {
         if($this->Request->isPost() && !empty($this->params['file'])){
          // $this->params['file'] hold the information about the uploaded file
          Ak::debug($this->params['file']);
          Ak::file_puts-contents(); // use this if you want to make your code portable.
         }
    }
    

    A GMail style file uploading is also available in Akelos. See the inline documentation for details.

    •  
      CommentAuthorpeter
     

    Thank you Bermi, these look like good starting points! I'll try to get this working within the next couple of days and post back my solution.

    Asset servers wouldn't be my favorite solution to this, though, as I like everything that belongs to a client to be in the same place.

    •  
      CommentAuthorjayro
     
    i tend to use the same pattern of /Model/id/filename.jpg as well and like using after_save methods to handle the saving and thumbnail processing for images.

    I am interested in seeing how other akelos users are handling uploads and I would be extremely interested in seeing a short writeup/tutorial about the process that is recommended for file handling with akelos.
    • CommentAuthorrevmagi
     
    Hello, I am new new php programmer and even newer to frameworks. As stated in another post, I am giving many a go and I do like Akelos. Could someone share an example of uploading an image file that would store the file locally renamed, associated with the user, and retreavable. I know this is a bit to ask, I can see this in standard php, but trying to get my head around it in OO and the framework. I do understand if it is to much. The small test project I am working on needs to allow client to upload 2 pictures along with their bio that can be shown in their VIew page later.

    Thanks in advance if anyone has the time.
    • CommentAuthormkhatib
     

    Hello All, I am trying to Upload file (image), i've tried the gmail-like upload method, and i've followed what is said in the helper file that bermi posted, but It didn't work. It Gives me a JavaScript Error:

    $H is not defined [Break on this error] _file_uploader_current_uploads : $H()...

    and ...

    FileUploader has no properties [Break on this error] FileUploader.start('PostForm', {partial:true}); // Change "form_id" for the id...

    and i've tried to use the old php method, but it didn't work too.

    Here's the code i used: $target_path = "/editorialBlog/public/uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; }

    and here's the error msgs:

    > Warning: move_uploaded_file(/editorialBlog/public/uploads/avg.xlsx) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\Dev\xampp\htdocs\editorialBlog\app\controllers\post_controller.php on line 67

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Dev\xampp\tmp\php76.tmp' to '/editorialBlog/public/uploads/avg.xlsx' in D:\Dev\xampp\htdocs\editorialBlog\app\controllers\post_controller.php on line 67 There was an error uploading the file, please try again! Warning: Cannot modify header information - headers already sent by (output started at D:\Dev\xampp\htdocs\editorialBlog\app\controllers\post_controller.php:67) in D:\Dev\akelos_framework\lib\AkResponse.php on line 109 Warning: Cannot modify header information - headers already sent by (output started at D:\Dev\xampp\htdocs\editorialBlog\app\controllers\post_controller.php:67) in D:\Dev\akelos_framework\lib\AkResponse.php on line 109