uploade file

leonte54 26 Jul, 2008
hi, sorry for my english
in my form, if i insert in Form tag attachment: enctype='multipart/form-data' the files uploaded but the filename don't result in DB, but if i dont' insert enctype='multipart/form-data' the namefile result but any file is uploaded.
Can you help me, please.
Tank you
Max_admin 26 Jul, 2008
Hi leon,

in the Auto generated tab you will need to replace $_POST['file_name' ] with $_FILES['file_name']['name']

cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
leonte54 27 Jul, 2008
Hi Max,
thank's for reply.
I post my Auto generated code because It does not work.
Please, can you tell me where is my mistake?

cheers

leonte54

<?php 
	$database =& JFactory::getDBO();
	srand((double)microtime()*10000);
	$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16);
	
$database->setQuery( "INSERT INTO #__chronoforms_1 VALUES  (
'' , '".$inum."','". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , 


'".JRequest::getVar('avviso','', 'post', 'string', '' )."' , 
'".JRequest::getVar('go','', 'post', 'string', '' )."');" );


if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
$_POST['avviso' ] with $_FILES['avviso']['name'];
?>
GreyHead 27 Jul, 2008
Hi leonte54,

Max has given you the code we use for Joomla 1.0.x and you have Joomla 1.5.x.

Try replacing:
'".JRequest::getVar('avviso','', 'post', 'string', '' )."' , 
with
'".JRequest::getVar('avviso','', 'files['name']', 'string', '' )."' , 
I'm not at all sure if that will work, if it doesn't I can do some research and find the way to access the $_FILES array in Joomla 1.5.x

I think that there may also be some problems in that this will give you the name of the uploaded file, not the name it was saved under (ChronoForms adds a suffix to avoid problems with duplicate file names).

Bob
Max_admin 27 Jul, 2008
Hi,

this is the JRequest variables list :

http://forum.joomla.org/viewtopic.php?f=476&t=255864

if the code provided by Bob didn't work, you can try to replace his 2nd line of code with this :

$_FILES['avviso']['name']


Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
leonte54 04 Aug, 2008
Hi,
I tried codes suggested by you but for the first and second code the error is the same:
the file upload but its name does not appear in the database.
For solutions n.3/4/5 the error is:
Parse error: syntax error, unexpected T_STRING in /membri/itcorion/components/com_chronocontact/chronocontact.php(571) : eval()'d code on line 8

Other codes that do not involve uploading files, is operating normally

Thanks


<?php 
	$database =& JFactory::getDBO();
	srand((double)microtime()*10000);
	$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16);
	
$database->setQuery( "INSERT INTO #__chronoforms_2 VALUES  (
'' , '".$inum."','". date('Y-m-d')." - ".date("H:i:s")."',
'".$_SERVER['REMOTE_ADDR']."' ,
'".JRequest::getVar('cod_asta', '', 'post', 'string', '' )."' ,
'".JRequest::getVar('avviso', '', 'post', 'string', '' )."' ,
'".JRequest::getVar('invio','', 'post', 'string', '' )."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}

header("location: index.php?option=com_content&view=article&id=44");
?>



2) -
'".JRequest::getVar('avviso', '', $_POST['avviso' ], 'string', '' )."' ,

3) -
'".JRequest::getVar('avviso', '', $_FILES['avviso']['name'] 'string', '' )."' ,

4) -
'".JRequest::getVar('avviso', 'files['name']', 'post', 'string', '' )."' ,

5) -
'".JRequest::getVar('avviso', '', 'files['name']', 'string', '' )."' ,
Max_admin 04 Aug, 2008
Hi leaonte,

for file names to appear in the database, there is one line hack to chronoconatct.php, this change is added to the new BETA release, and you need NO changes in the Autogenerated code, here its :

change this code :

if ( $fileok ) {					
	$uploadedfile = handle_uploaded_files($original_name, $filename);


to be :

if ( $fileok ) {					
	$uploadedfile = handle_uploaded_files($original_name, $filename);
	$_POST[$allowed_s2[0]] = $filename;
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 04 Aug, 2008
Hi leonte54,

I'm not sure where they've come from but those
  & 
tags certainly don't belong in this code.

Bob
leonte54 06 Aug, 2008
hi,
thank you very much for your answer, the problem now is resolved, it works very well.
guessdon 04 Feb, 2009
Would u describe the steps u take to solve the problem

thanks
GreyHead 04 Feb, 2009
Hi guessdon,

This is an old thread talking about a previous release of ChonoForms.

Exactly what problem do you need help with??

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