Forums

Handle with File Upload in php

BNDragon 22 Jan, 2015
Hi there,

I have a form to edit profile in CB, I make a button to go to the form in profile (hack core unfortunately) and it works good on load the user data.

I'm reading the data with a Data Reading Action, but I'm updating with a custom code, because I need some custom functions.
I'm updating everything good, but my problem is the File upload (user avatar). I don't know how to handle it.

I need to give a custom name to the file like "usernameDateTime.jpg" and save it in "images/comprofiler".

How can I do it in php?

Thanks in advance,
BN
BNDragon 26 Jan, 2015
Hi,

Can someone help me here please?

Thanks,
BN
GreyHead 26 Jan, 2015
Answer
1 Likes
HI BN,

Again there is a Joomla! JFile class for doing this see JFile::upload()

Bob
BNDragon 26 Jan, 2015
Hi Bob,

This is what I need, like I said in the other post, I'm not familiarity with the joomla functions, the only I knew was the db and user functions.

I really appreciate your help, very thanks once again.
BN
GreyHead 27 Jan, 2015
Hi BN,

Sorry, but I can’t write Joomla! tutorials for you - Googling should find you a few.

Bob

PS I'd feel a lot happier replying to your posts if you remove the flappy image from your signature. I find it very distracting, not to mention large.
BNDragon 27 Jan, 2015
Hi Bob,

Didn't saw this last post. I found a way, Not working 100% but almost there, only need one tip.

I have a event switcher and I'm trying to know if there is a a file to upload, but it doesn't work.

Here's my code:
<?php
if ( isset($form->data['avatar']) ) {
  return 'success';
}
else
{return 'fail';}
?>


The $form->data['avatar'] field is the upload field.
I'm using the event switcher because I need different types of saves.

BN

p.s. I've removed the flappy, I'm sorry, I don't wanted to annoying nobody.
BNDragon 28 Jan, 2015
Hi Bob,

Sorry to bump, I know this a solved one, but can you give me just a little help here?

BN
This topic is locked and no more replies can be posted.