The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Jun 13, 2011 9:11 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Dec 11, 2010 11:23 pm
Posts: 24
Location: london
I have been stuck on a component i'm building for quite sometime now. On clicking on the new button a page is displayed in view whose function is to collect info such as name, publish or unpublish, client and so on and so forth. The problem is, i need a field for uploading images.

My question is, i have a save function, function store(), in the model which uses the table to save items from the form into the database table by doing the table bind, check_in, save e.t.c.

So, i have created the form fields for all items i need in the tmpl folder of my view but what i really need is for all the items in the form field to be saved to the table however, i need only the url path to the image and image name to be saved to the database with the image itself saved to the file folder system of joomla. I presume i'll do that with the help of JFolders.

I'v searched google but havent quite found what i'm looking for. Could someone with experience with this shed some light on how i could do this?

_________________
http://www.samybaxy.net


Top
 Profile  
 
PostPosted: Mon Jun 13, 2011 10:30 am 
Joomla! Master
Joomla! Master
Online

Joined: Mon Oct 27, 2008 9:27 pm
Posts: 13633
Location: Akershus, Norway
This is from the Annonces extension:

Code:
function enregistrerPhoto( $file, $photoId, $pMaxUploadKoSize, $comp )
   {
      global $mainframe;
      $result = true;
      if ( !empty($file['name']) ) 
      {
         jimport('joomla.filesystem.file');
         
         //check the image
         $check = $this->check($file, (int) $pMaxUploadKoSize);
         
         if ($check == false) {
            return false;
         }
         
         //sanitize the image filename
         $filename = $photoId.'.jpg';
         $filepath = $this->photoPathTemp . DS . $filename;

         if ( JFile::upload($file['tmp_name'], $filepath))
         {
            // On redimensionne la photo
            $result = $this->dimensionnerPhotos( $filename );
         }
         /**else {
            JError::raiseError( 500, JText::_( 'UPLOAD FAILED' ) );
            return false;
         }*/
      }
      return $result;
   }


Top
 Profile  
 
PostPosted: Mon Jun 13, 2011 10:39 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Dec 11, 2010 11:23 pm
Posts: 24
Location: london
Hello again, thanks for your update. The question is i have been seeing this code but dont even know how to implement it. I already have a store function that saves data from the text input boxes using jtable. Now i've added a an input file upload input box. How do i use that function with the rest of the other text data saved to the db.

Thank you

_________________
http://www.samybaxy.net


Top
 Profile  
 
PostPosted: Mon Jun 13, 2011 10:57 am 
Joomla! Master
Joomla! Master
Online

Joined: Mon Oct 27, 2008 9:27 pm
Posts: 13633
Location: Akershus, Norway
Get the extension and study the source files.

http://extensions.joomla.org/extensions/ads-a-affiliates/classified-ads/11937


Top
 Profile  
 
PostPosted: Mon Jun 13, 2011 11:07 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Dec 11, 2010 11:23 pm
Posts: 24
Location: london
Thank you

_________________
http://www.samybaxy.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group