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.
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.
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
1 to 6 of 6