Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
Hi. I'm quite new in akelos. I'm trying to create file (in fact: image) upload script. I've got problem with passing file content to Ak::file_put_contents() function. My view:
<%= start_form_tag {'controller'=>'panel'}, {'enctype'=>'multipart/form-data'} %>
<h1>Dodaj pracę</h1>
<label for="type">Typ</label><input id="file_type" type="file" name="file_type" /><br />
<label for="screen">Zrzut</label><input type="file" id="screen" name="screen" /><br />
<input type="submit" name="add" value="Wyślij" />
<?php echo $form_tag_helper->end_form_tag() ?>
My controller:
Ak::debug($this->params['screen']);
if($this->params['file_type']){
$type= explode('.',$this->params['file_type']['name']);
Ak::file_put_contents('works/'.time().'.'.$type[1],$this->params['file_type']);
}
$type= explode('.',$this->params['screen']['name']);
Ak::file_put_contents('works/'.time().'_t.'.$type[1],$this->params['screen']);
$this->redirectTo(array('controller'=>'panel'));
file is created, however, content is... text, simply- it`s collection of data, simmilar as in Ak::debug($this->params['screen']); .
How can I pass real file content(jpeg file) ?
Sorry for my language errors, it`s not my native language.
Hello krzyzak,
I got the same issue and finally i've used the native php function. Here a sample :
$content is your screen in your exemple
protected function uploadFile($file_name, $content, $content_dir){
$tmp_file = $content['tmp_name'];
if( !is_uploaded_file($tmp_file) )
{
$this->flash['error'] = Ak::t("The file can't be uploaded");
$this->redirectTo(array('controller'=>'page'));
}
if( !move_uploaded_file($tmp_file, $content_dir.DS.$file_name) )
{
$this->flash['error'] = Ak::t("The file can't be moved");
$this->redirectTo(array('controller'=>'page'));
}
}
o.0 native php functions ? ehh, I'm using framework to avoid this situation. We should open new ticket on akelos bugtracker- however, I'll wait for developer's answer :)
1 to 3 of 3