Hello!
I’m having trouble uploading an image to the server using simple functions and a simple template containing only FileUpload type named slika.
I didn’t find any simple examples on the forum.
These are my functions that I’m using to save and get my images:
function save_picture($file,$resouce_id)
{
egw_link::attach_file(‘app’,$resouce_id,array(
‘tmp_name’ => $file[‘tmp_name’],
‘name’ => self::PICTURE_NAME,
‘type’ => ‘image/jpeg’,
));
}
function get_picture($res_id=0,$fullsize=false)
{
$picture = egw_link::vfs_path(‘app’,$res_id,self::PICTURE_NAME,true); // vfs path
if ($fullsize)
{
$picture = egw::link(egw_vfs::download_url($picture));
}
else
{
$picture = egw::link('/etemplate/thumbnail.php',array('path' => $picture));
}
return $picture;
}
When I’m calling the $this->save_picture($content[‘slika’],$id); the picture does not show in FileManager in /apps/app/$id/ folder. Folder doesn’t even exist. I took this code for saving and retrieving images from eGW Resources application but I can’t get it to work on my app. Do I have to have some special rights to upload an image or file? Are there any preconditions that I have to do to enable file uploading?
Thank You.