The Joomla! Forum ™



Forum rules


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



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
PostPosted: Wed Aug 01, 2007 3:45 pm 
Joomla! Intern
Joomla! Intern

Joined: Wed Aug 01, 2007 3:32 pm
Posts: 77
Hi out there.
I'm new developping for Joomla!. I use the 1.5 RC.
I'm writing a component - after having looked at your MVC-Tutz I understand a lot but not everything.
I'm wondering where and how I can store imaged a user has chosen in a form.
The Component is an (volleyball-)exercise-look up-and-store-component which can help trainers to develop a training...
Registered users shall add exercises to the db and they can use therefor a form.
Every exercise shall be able to hold up to three images.
And now I'm wondering how I can upload them (in a directory) or how to store them in the db.
Greetz and thanks
Aljoscha Peters


Top
 Profile  
 
PostPosted: Thu Aug 02, 2007 2:37 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jul 24, 2007 3:03 pm
Posts: 5
Hi Aljoscha,

i have the same problem - did you find a Solution?

I thought about using the mediamanager for uploading the pictures.

And just save the link to the image.

Dave


Top
 Profile  
 
PostPosted: Thu Aug 02, 2007 3:10 pm 
Joomla! Intern
Joomla! Intern

Joined: Wed Aug 01, 2007 3:32 pm
Posts: 77
No, sry. I haven't think about it so far. The directory of the MediaManager (or maybe /images/comp_name) is a possibility. Let me think about it the next two days. I will post you when I'm done with this part of my comp.
I haven't find a function for uploading an image (or other) file. Maybe someone can help how to do this with the J!-API. Otherwise I must go to php-roots  :(


Last edited by NeoAnderson1982 on Thu Aug 02, 2007 3:34 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Aug 02, 2007 7:21 pm 
User avatar
Joomla! Virtuoso
Joomla! Virtuoso

Joined: Sat Sep 24, 2005 11:01 pm
Posts: 4785
Location: Toronto, Canada
Look at the com_installer component as an exmaple, or the com_media component to see how they do it.

Ian


Top
 Profile  
 
PostPosted: Fri Aug 03, 2007 10:43 am 
Joomla! Intern
Joomla! Intern

Joined: Wed Aug 01, 2007 3:32 pm
Posts: 77
Hey Rave,
I will try another solution. I will use the editor. There a user can upload and choose images directly.
Aber ich kann dir empfehlen mal den installer etwas genauer unter die Lupe zu nehmen, da ist ein Abschnitt, der dir genau zeigt,
wie der Upload einer Datei mit dem Joomla-Framework funktioniert. Hier ein Ausschnitt aus der install.php (admin->comp->installer->models):
Code:
function _getPackageFromUpload()
   {
      // Get the uploaded file information
      $userfile = JRequest::getVar('install_package', null, 'files', 'array' );

      // Make sure that file uploads are enabled in php
      if (!(bool) ini_get('file_uploads')) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLFILE'));
         return false;
      }

      // Make sure that zlib is loaded so that the package can be unpacked
      if (!extension_loaded('zlib')) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLZLIB'));
         return false;
      }

      // If there is no uploaded file, we have a problem...
      if (!is_array($userfile) || $userfile['size'] < 1) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('No file selected'));
         return false;
      }

      // Check if there was a problem uploading the file.
      if ( $userfile['error'] )
      {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLUPLOADERROR'));
         return false;
      }

      // Build the appropriate paths
      $config =& JFactory::getConfig();
      $tmp_dest    = $config->getValue('config.tmp_path').DS.$userfile['name'];
      $tmp_src   = $userfile['tmp_name'];

      // Move uploaded file
      jimport('joomla.filesystem.file');
      $uploaded = JFile::upload($tmp_src, $tmp_dest);

      // Unpack the downloaded package file
      $package = JInstallerHelper::unpack($tmp_dest);

      return $package;
   }

You don't need zlib or unpack. Change the $tmp_dest to the final destination where the file should be (including the filename) and you're done.  ;)
Greetz Aljoscha


Top
 Profile  
 
PostPosted: Wed Aug 08, 2007 8:50 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Oct 23, 2005 6:49 pm
Posts: 5
Any luck with the component? It sounds like a useful component. I wanted to develop the same sort of thing. Kind of like endurancelog component, except with more options for exercises instead of just sports. And the ability to track progress / improvement. How far along are you on the component ?


Top
 Profile  
 
PostPosted: Wed Aug 08, 2007 3:48 pm 
Joomla! Intern
Joomla! Intern

Joined: Wed Aug 01, 2007 3:32 pm
Posts: 77
I've seen that Galileo Computing will bring up a book in september about developping in Joomla! I will wait for it, because I can't get a clue how to store the content of an editor of a form in the database...
The tutz don't give a hint to it (in my opinion) and the article-comp has not got a good comment to see through the techniques...
Maybe you can give me the clue???


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 



Who is online

Users browsing this forum: No registered users and 15 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