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  [ 26 posts ] 
Author Message
PostPosted: Thu Oct 29, 2009 9:33 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 19, 2009 1:30 pm
Posts: 10
Hi,

I want to add extra fields link city, age and upload photo option in new user signup page. And uploaded image has to move in desired folder which i created in the Media Manager and only the path of the image store in the database user table.

If anyone knows, please help me to do.

Thanks in advance.

VP


Top
 Profile  
 
PostPosted: Wed Dec 16, 2009 10:43 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 04, 2009 12:35 pm
Posts: 15
Quote:
I want to add extra fields link city, age and upload photo option in new user signup page. And uploaded image has to move in desired folder which i created in the Media Manager and only the path of the image store in the database user table.


I have a same requirement.. Is there any component to manage user like JUser component for joomla 1.5.. Community builder dint work for me..

Please help....

_________________
www.sigmainfo.net


Top
 Profile  
 
PostPosted: Thu Dec 24, 2009 6:38 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 19, 2009 1:30 pm
Posts: 10
Hi,

I did not used any component separately for this. I added file input in registration default.php page and uploaded code in controller.php page.


Try this,

$file = JRequest::getVar( 'image', '', 'files', 'array' );
$uuname = JRequest::getVar('username', '', 'post', 'username');

if(isset($file['name']) && $file['name'] != '')
{
jimport('joomla.filesystem.file');

$ext = JFile::getExt($file['name']);

$filename = JPATH_SITE . DS . 'images' . DS .'user_photos'.DS. $uuname.$file['name']; // Create the folder called user_photos in images

if (!JFile::upload($file['tmp_name'], $filename)) {
$this->setRedirect("index.php", "Image Upload failed");
return;
}
}


Let me know if have any doubt.


Top
 Profile  
 
PostPosted: Sat Dec 26, 2009 8:39 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Fri Aug 19, 2005 2:53 pm
Posts: 675
Location: Greece
CB has this built-in as of CB 1.2.1.

_________________
Nick (nant)
Member of the Community Builder Team http://www.joomlapolis.com
CBSubs - Most powerful Joomla Paid Subscription System http://www.joomlapolis.com/cb-solutions/cbsubs


Top
 Profile  
 
PostPosted: Mon Feb 08, 2010 4:55 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 14, 2010 8:22 am
Posts: 9
where should I put above code in controller.php? I mean to say I should create another function or can I put within in-built function.


Top
 Profile  
 
PostPosted: Mon Feb 08, 2010 4:57 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 14, 2010 8:22 am
Posts: 9
where should I put above code in controller.php? I mean to say I should create another function or can I put within in-built function.


Top
 Profile  
 
PostPosted: Mon Feb 08, 2010 6:28 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 19, 2009 1:30 pm
Posts: 10
No need to create new function. You can paste within the in-built function.


Top
 Profile  
 
PostPosted: Sun Feb 14, 2010 8:12 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 14, 2010 8:22 am
Posts: 9
I used above code in in built function save() and register_save in controller.php My photo is uploaded but file name is not saved in database.Do you have any idea? Please Help..


Top
 Profile  
 
PostPosted: Mon Feb 15, 2010 6:19 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 19, 2009 1:30 pm
Posts: 10
For that you have to add extra field in "#_users" table in your joomla database and add the variable (field name) to the following file "libraries/joomla/database/table/user.php"


the file input name, database field name and the variable which you insert in the user.php file should be same.


Top
 Profile  
 
PostPosted: Mon Feb 15, 2010 7:57 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 14, 2010 8:22 am
Posts: 9
I used same input name, database field and variable and named it "photo" but it only works when I remove enctype from form tag but when I remove enctype photo is not uploaded only filename is saved in the database. what I am going to do is I just want to submit data and upload image with single "submit" button. I don't know what to do. Please help..


Top
 Profile  
 
PostPosted: Tue Feb 16, 2010 7:29 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 14, 2010 8:22 am
Posts: 9
Cheers Its working
Thanks VPriya_04 for your file upload code and related information about it. I used following code after upload code before last cur lee bracket
$db =& JFactory::getDBO();
$query="UPDATE jos_users SET photo = '".$file['name']."' WHERE id = '".$userid."'";
$db->setQuery($query);
$db->query();
$this->setRedirect("index.php", "Image saved failed");
return;


Top
 Profile  
 
PostPosted: Tue Feb 16, 2010 7:50 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Aug 19, 2009 1:30 pm
Posts: 10
Cool...Welcome


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 5:47 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Mar 02, 2010 5:42 pm
Posts: 2
Hi,

where this code will be added

$db =& JFactory::getDBO();
$query="UPDATE jos_users SET photo = '".$file['name']."' WHERE id = '".$userid."'";
$db->setQuery($query);
$db->query();
$this->setRedirect("index.php", "Image saved failed");
return;


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 5:51 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue Mar 02, 2010 5:42 pm
Posts: 2
I added this code in the both functions save() and register_save()

.
.
.
$file = JRequest::getVar( 'image', '', 'files', 'array' );
$uuname = JRequest::getVar('username', '', 'post', 'username');

if(isset($file['name']) && $file['name'] != '')
{
jimport('joomla.filesystem.file');

$ext = JFile::getExt($file['name']);

$filename = JPATH_SITE . DS . 'images' . DS .'user_photos'.DS. $uuname.$file['name']; // Create the folder called user_photos in images

if (!JFile::upload($file['tmp_name'], $filename)) {
$this->setRedirect("index.php", "Image Upload failed");
return;
}
$db =& JFactory::getDBO();
$query="UPDATE jos_users SET image = '".$file['name']."' WHERE id = '".$userid."'";
echo $query;
$db->setQuery($query);
$db->query();
$this->setRedirect("index.php", "Image saved failed");
return;
}
.
.
.
.
.

and create new field "image" in the _users table..also add variable as a same name $image

when I attempt to create new account it says "Image saved failed"

I checked in the images folder image uploaded successfully but in the database no data input..Please help..

Thanks
Ehsan


Top
 Profile  
 
PostPosted: Sun Apr 25, 2010 9:25 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Apr 25, 2010 9:18 am
Posts: 1
If you are having problems, this is what I did:

Note: I'm using Alpharegistration but it should work on the regular controller.

I have this in the register_save() function:
Code:
// Image Save
      $file = JRequest::getVar( 'image', '', 'files', 'array' );
      $uuname = JRequest::getVar('username', '', 'post', 'username');
      
      if(isset($file['name']) && $file['name'] != '')
      {
      jimport('joomla.filesystem.file');
      
      $ext = JFile::getExt($file['name']);
      
      $filename = JPATH_SITE . DS . 'images' . DS .'user_photos'.DS. $uuname.$file['name']; // Create the folder called user_photos in images
      
         if (!JFile::upload($file['tmp_name'], $filename)) {
            $this->setRedirect("index.php", "Image Upload failed");
            return;
         }
         $this->saveImage( $user->id, $filename );
      }


then created a separate function called saveImage():
Code:
function saveCaidimage( $userid, $filename )
   {
      $db =& JFactory::getDBO();
      $user = & JFactory::getUser();   
   
      $query="UPDATE jos_users SET image = '".$filename."' WHERE id = '".$userid."'";
      $db->setQuery( $query );
      $db->query();   
   }


Hope this helps.


Top
 Profile  
 
PostPosted: Thu Mar 24, 2011 1:22 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Mar 24, 2011 1:18 am
Posts: 1
Hi everyone.
How can file upload option be added to user registration form in Joomla 1.6?
Thanks in advance.


Top
 Profile  
 
PostPosted: Mon Apr 25, 2011 2:23 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri May 29, 2009 7:45 am
Posts: 11
I am also facing same problem... similar to "yklsorok" or How to assign each user have own root directory in media manager... Please reply... thinking you... >:(


Top
 Profile  
 
PostPosted: Sat May 28, 2011 7:21 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed May 18, 2011 11:04 pm
Posts: 40
lramos85 wrote:
If you are having problems, this is what I did:

Note: I'm using Alpharegistration but it should work on the regular controller.

I have this in the register_save() function:
Code:
// Image Save
      $file = JRequest::getVar( 'image', '', 'files', 'array' );
      $uuname = JRequest::getVar('username', '', 'post', 'username');
      
      if(isset($file['name']) && $file['name'] != '')
      {
      jimport('joomla.filesystem.file');
      
      $ext = JFile::getExt($file['name']);
      
      $filename = JPATH_SITE . DS . 'images' . DS .'user_photos'.DS. $uuname.$file['name']; // Create the folder called user_photos in images
      
         if (!JFile::upload($file['tmp_name'], $filename)) {
            $this->setRedirect("index.php", "Image Upload failed");
            return;
         }
         $this->saveImage( $user->id, $filename );
      }


then created a separate function called saveImage():
Code:
function saveCaidimage( $userid, $filename )
   {
      $db =& JFactory::getDBO();
      $user = & JFactory::getUser();   
   
      $query="UPDATE jos_users SET image = '".$filename."' WHERE id = '".$userid."'";
      $db->setQuery( $query );
      $db->query();   
   }


Hope this helps.


i tried it exactly as u said...but getting this error

Warning: Failed to move file!
Image Upload failed!

i googled it and then changed the permissions on "user_photos" folder to 777 but dint work! :(

any idea how to make it work??


Top
 Profile  
 
PostPosted: Mon May 30, 2011 4:45 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 13, 2009 5:13 am
Posts: 20
Just a reminder to the core hackers that it will make upgrading versions a little difficult. It would be better to go with a component like Community Builder, Jomsocial, etc..


Top
 Profile  
 
PostPosted: Mon May 30, 2011 5:37 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed May 18, 2011 11:04 pm
Posts: 40
ok, i got it done!! :)

i wasn't adding form field in administrator/components/com_users/views/user/tmpl/form.php, so it was giving me that error

Warning: Failed to move file!
Image Upload failed!


Top
 Profile  
 
PostPosted: Mon May 30, 2011 5:43 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed May 18, 2011 11:04 pm
Posts: 40
and to add file-name in database i simply used

Code:
$user->set('image', $filename);


instead of

Code:
$this->saveImage( $user->id, $filename );


P.S there is no need to add code to save() and register_save() functions, adding it to only register_save() will do the work!!


Top
 Profile  
 
PostPosted: Wed Dec 14, 2011 6:53 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Dec 06, 2011 7:37 am
Posts: 12
I have same problem with file upload
I used same input name, database field and variable and named "image" but it only works when I remove enctype from form tag but when I remove enctype photo is not uploaded only filename is saved in the database.
i have also declared var $image= null; in user.php


Top
 Profile  
 
PostPosted: Fri Dec 16, 2011 3:42 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed May 18, 2011 11:04 pm
Posts: 40
yeah, enctype is must thing, but make sure you are adding extra fields in all forms


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 1:40 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Mar 05, 2012 1:34 pm
Posts: 1
I want to add upload file field in user registration to let users upload their c.v ...I put this code in default.php
<input type="file" id="upload" name="upload" value="<?php echo $this->escape($this->user->get( 'upload' ));?>" maxlength="100" />

And created "upload" field in database table "jos_users". when user submit the form the database "upload" field filled with the title of file uploaded only...sure i have to make another step maybe in controller.php...Anyone can help!


Top
 Profile  
 
PostPosted: Mon Apr 16, 2012 8:21 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Nov 28, 2011 6:07 am
Posts: 7
i have similiar problem like LinaFoksha

I used same input name, database field and variable and named it 'image'. Put the upload code above into function register_save() and function save() in controller.php.

The image name succesfully write into database field, but the image itselt wouldnt uploaded into dest folder (actually, after click the register button, i cant see uploading process either)

Here the file input i used :
Code:
<tr>
         <td class="paramlist_key">
            <label id="image" for="image" class="label"><?php echo JText::_( 'Scan Card ID' ); ?></label>
         </td>
         <td class="paramlist_value" >
         <form name="image" method="post" enctype="multipart/form-data" >
         <input class="inputbox" type="file" id="image" name="image" value="<?php echo $this->escape($this->user->get( 'image' ));?> />"
         </form>
         </td>
      </tr>


Top
 Profile  
 
PostPosted: Wed May 02, 2012 10:07 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Nov 28, 2011 6:07 am
Posts: 7
finally i figure out how to make some extra field. Was working on jomsocial registration form.

Thanks fatimasabir and all guys dan girls above

cheers


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 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