Forums

File Upload: Path not stored in database anymore

moontear 04 Mar, 2008
Hello there,

I don't know what changed, but strangely the path to the uploaded files is not stored in the database anymore, the files are uploaded though.

The form code for the file upload is:
<input type="file" name="cvupload" id="cvupload" />


The code for field names & allowed exensions is: cvupload:pdf|doc|zip|rar|docx|xls|txt

autogenerated code is:
<?php 
	global $database;
	
$database->setQuery( "INSERT INTO #__chronoforms_3 VALUES  (
'' , '". date('Y-m-d')." - ".date("H:i:«»s"«»)."', '".$_SERVER['REMOTE_ADDR']."' , '".$_POST['first_name']."' , '".$_POST['last_name']."' , '".$_POST['address_1']."' , '".$_POST['address_2']."' , '".$_POST['postal']."' , '".$_POST['city']."' , '".$_POST['country']."' , '".$_POST['email']."' , '".$_POST['confirm_email']."' , '".$_POST['phone']."' , '".$_POST['forum']."' , '".$_POST['accomodation']."' , '".$_POST['private_hosting']."' , '".$_POST['motivationupload']."' , '".$_POST['cvupload']."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>


no on Submit after/before e-mail code.

Maybe I accidently deleted something, but all I want is that the filepaths get stored again in the cvupload & motivationupload fields.

Thank you
Dennis
GreyHead 05 Mar, 2008
Hi Dennis,

I'm not sure what is happening, you have $_POST['cvupload'] in the AutoGenerated code but this will be empty as the file name is not in $_POST unless you put it there.

Try replacing that with $_FILES[$name]['cvupload'] etc.

Bob
moontear 05 Mar, 2008
No luck, still NOTHING gets posted in the cv+motivationupload fields. The autogenerated code looks like this now:
<?php 
	global $database;
	
$database->setQuery( "INSERT INTO #__chronoforms_3 VALUES  (
'' , '". date('Y-m-d')." - ".date("H:i:«»s"«»)."', '".$_SERVER['REMOTE_ADDR']."' , '".$_POST['first_name']."' , '".$_POST['last_name']."' , '".$_POST['address_1']."' , '".$_POST['address_2']."' , '".$_POST['postal']."' , '".$_POST['city']."' , '".$_POST['country']."' , '".$_POST['email']."' , '".$_POST['confirm_email']."' , '".$_POST['phone']."' , '".$_POST['forum']."' , '".$_POST['accomodation']."' , '".$_POST['private_hosting']."' , '".$_FILES[$name]['motivationupload']."' , '".$_FILES[$name]['cvupload']."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>


Was I supposed to replace $name with something?<br><br>Post edited by: moontear, at: 2008/03/05 17:15
GreyHead 05 Mar, 2008
Hi moontear,

Sorry, not thinking too straight and too busy to write test code.

Found this in the forums here

find the $_POST['file_field_name'] and replace it with $_FILES['file_field_name']['name']



Bob
moontear 06 Mar, 2008
My bad.

The problem came up because of an Chronoforms update. I didn't note anywhere that I applied the hack from this post.

My chronoforms.php line 243 and following looks like this now:
if ( $uploadedfile ) {
$attachments[$allowed_s2[0]] = $uploadedfile;
}
$_POST[$allowed_s2[0]] = "http://www.xxx.org/components/com_chronocontact/upload/".basename($uploadedfile);
}


And it works like a charm again. Thanks for your efforts!

Dennis

PS: I suggest adding this hack to the next version of Chronoforms - like a little checkbox in the Upload tab saying "post URLs to table" or something similar.<br><br>Post edited by: moontear, at: 2008/03/06 11:18
GreyHead 06 Mar, 2008
Hi Dennis,

Well remembered! Good suggestion too, hopefully Max wiil pick it up.

Bob<br><br>Post edited by: GreyHead, at: 2008/03/06 17:32
This topic is locked and no more replies can be posted.