close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

File Upload not saving file name to database, but saving other fields

Thread begun 9/30/2019 10:09 am by Nathon Jones Web Design | Last modified 9/30/2019 1:01 pm by Ray Borduin | 1064 views | 7 replies |

Nathon Jones Web Design

File Upload not saving file name to database, but saving other fields

Any idea why this isn't saving the file name to database, but is saving the other data?

The form...

<form name="FORMupload" method="POST" action="">
<div class="form-group">
<label for="SMCuploadFILE">Please select a file:</label>
<input type="file" class="form-control-file" id="SMCuploadFILE" name="SMCuploadFILE">
</div>

<button type="submit" class="btn btn-primary mb-2" name="BTNupload">Upload File</button>
<input type="hidden" value="<?php echo $_SESSION['NEWformID']; ?>" name="HIDEformSTEP5ID">
<input type="hidden" value="<?php echo $_SESSION['NEWuserID']; ?>" name="HIDEformUSERID">
</form>



The server behaviours...

<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "uploads/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["BTNupload"]) || isset($_POST["BTNupload_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "SMCuploadFILE", "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
}
?>
<?php
if (isset($_POST["BTNupload"]) || isset($_POST["BTNupload_x"])) {
$InsertQuery = new WA_MySQLi_Query($csdbmysqli);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "SMCuploads";
$InsertQuery->bindColumn("SMCformID", "i", "".((isset($_POST["HIDEformSTEP5ID"]))?$_POST["HIDEformSTEP5ID"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("SMCuserID", "i", "".((isset($_POST["HIDEformUSERID"]))?$_POST["HIDEformUSERID"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("SMCuploadFILE", "s", "".$WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverFileName"] ."", "WA_DEFAULT");
$InsertQuery->saveInSession("NEWuploadID");
$InsertQuery->execute();
$InsertGoTo = "health-screening-form.php?tab5=1";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>



Thank you.
NJ

Sign in to reply to this post

Nathon Jones Web Design

Just to add that I've also tried...

$InsertQuery->bindColumn("SMCuploadFILE", "s", "".$WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverSimpleFileName"]  ."", "WA_DEFAULT");



...without success.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Your <form> tag needs to have enctype="multipart/form-data"

Sign in to reply to this post
Did this help? Tips are appreciated...

Nathon Jones Web Design

It has been an incredibly long....year.
Thank you Ray.
NJ

Sign in to reply to this post

Nathon Jones Web Design

Is it possible to restrict the file types that can be uploaded?

Sign in to reply to this post

Ray BorduinWebAssist

You can use form validation to validate the file extension.

Sign in to reply to this post
Did this help? Tips are appreciated...

Nathon Jones Web Design

When I get to "Choose Variable to Validate" it lists...
SMCuploadFILE (which is the form field title and DB field)
SMCuploadFILE Field Name
SMCuploadFILE Temp Path
etc.

I also note:
SMCuploadFILE Extension

Shuold I be opting for one of those or just the SMCuploadFILE field name?
Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

You can just use the field from the Form directly... the $_POST value. And use file extension validation.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...