Can anyone point me in the right direction concerning the following:
I would like to add an upload option to my component in the backend to upload a picture. I would like to do it in a good 1.5 way. Does anyone have a piece of example code with the right API calls, so I can study it and take the code as a base?
Re: What API calls to add upload option?
Posted: Tue Sep 25, 2007 6:26 pm
by ianmac
I would take a look at the media manager in the backend.
Ian
Re: What API calls to add upload option?
Posted: Tue Oct 02, 2007 11:30 am
by zian974
Hi,
I made this to upload txt file for my component. this is the function i wrote, free inspirate by './administrator/components/com_installer/models/install.php'. I think it work for other type of file (png, jpg, ...).
To manipulate File and folder, you need to import JFile and JFolder class. I use JRequest::getVar with the attribute 'files'.
// Check if there was a problem uploading the file. if ( $userfile['error'] || $userfile['size'] < 1 ) { JError::raiseWarning('SOME_ERROR_CODE', 'Erreur de transfert du fichier' ); return false; }
// Check if there was a problem uploading the file. if ( $userfile['error'] || $userfile['size'] < 1 ) { JError::raiseWarning('SOME_ERROR_CODE', 'noooooo' ); return false; } else JError::raiseWarning('SOME_ERROR_CODE', 'yeeeees' );
// Register Extra tasks // wir mappen add zu edit... edit ist ja nix anders wie add nur mit gefüllter form etc.. $this->registerTask( 'add' , 'edit' ); $this->registerTask( 'upload' , 'upload' ); }
Re: What API calls to add upload option?
Posted: Wed Oct 03, 2007 6:16 am
by ianmac
check where you're getting your task from? And check to make sure it is being retrieved properly. You are sending it via get, and it might be looking for it via post.
Ian
Re: What API calls to add upload option?
Posted: Wed Oct 03, 2007 7:40 am
by ghostrifle
Uhh... I'm using POST to send the file.... so.... I have to differ between GET and POST while retrieving a task?... that's the thirst thing I read now considering joomla tasks.... where can I get further information about this topic and the GET and POST differences in joomla tasks !?
Thanx, Alex
Re: What API calls to add upload option?
Posted: Wed Oct 03, 2007 9:59 pm
by ghostrifle
Well... I found the error... I nested two forms ... it works now, thanx for your help !