close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Upload/Insert to Database: File Extension Question

Thread began 11/13/2018 1:33 pm by LWat85283715 | Last modified 12/06/2018 12:57 pm by Ray Borduin | 193 views | 14 replies |

LWat85283715

Upload/Insert to Database: File Extension Question

I have a page that inserts a record into the database and uploads a file. When it inserts the file name into the database, it doesn't include the file extension. How do I get the name and file extension to be added? Thanks

Sign in to reply to this post

Ray BorduinWebAssist

What did you use in your insert server behavior bindings? I think if you use "Server File Name", it should include the extension.

Sign in to reply to this post

LWat85283715

I tried multiple ones: Just the file name, extension, etc. None work to get the file name and extension. There is no Server Extension option in the list.

Sign in to reply to this post

Ray BorduinWebAssist

Please attach the file you are working on and I'll take a look to see what you have used as the binding and suggest the appropriate edits.

Sign in to reply to this post

LWat85283715

Thanks. Here is the file.

Attached Files
edit_addendum2.php
Sign in to reply to this post

Ray BorduinWebAssist

Your binding should be set to:

php:
<?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverFileName"]; ?>
Sign in to reply to this post

LWat85283715

So you are meaning this line needs to be changed?

$UpdateQuery->bindColumn("icon", "s", "".((isset($_FILES["icon"]))? preg_replace('/^.*\./', '', $_FILES["icon"]["name"]) :"") ."", "WA_DEFAULT");

Sign in to reply to this post

Ray BorduinWebAssist

I'm talking about updating it from the Server Behavior, not in the code.

If that is the column you want the image name saved into and you want to do it in the code, then the line would be:

$UpdateQuery->bindColumn("icon", "s", "".($WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverFileName"]) ."", "WA_DEFAULT");

Sign in to reply to this post

LWat85283715

Works great. If I have two file uploads on a page, would it look like this:

<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "agreements",
'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["submit"]) || isset($_POST["submit_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "file_pdf", "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
}
?>

<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["submit"]) || isset($_POST["submit_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "file_doc", "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
}
?>

<?php
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
$UpdateQuery = new WA_MySQLi_Query($sdpc_i);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "agreement_types";
$UpdateQuery->bindColumn("agreement_name", "s", "".((isset($_POST["agreement_name"]))?$_POST["agreement_name"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("description", "s", "".((isset($_POST["description"]))?$_POST["description"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("category", "s", "".((isset($_POST["category"]))?$_POST["category"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("public", "s", "".((isset($_POST["public"]))?$_POST["public"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("file_pdf", "s", "".($WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverFileName"]) ."", "WA_IGNORE");
$UpdateQuery->bindColumn("file_doc", "s", "".($WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverFileName"]) ."", "WA_IGNORE");
$UpdateQuery->bindColumn("addendum", "s", "".((isset($_POST["addendum"]))?$_POST["addendum"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("latest", "s", "".((isset($_POST["latest"]))?$_POST["latest"]:"") ."", "WA_IGNORE");
$UpdateQuery->addFilter("agreement_typesID", "=", "i", "".($_GET['agreement_typesID']) ."");
$UpdateQuery->execute();
$UpdateGoTo = "manage_state_agreements.php?state=" . $_GET['state'] . "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}

Sign in to reply to this post

Ray BorduinWebAssist

It would probably be:

$UpdateQuery->bindColumn("file_pdf", "s", "".($WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverFileName"]) ."", "WA_IGNORE");
$UpdateQuery->bindColumn("file_doc", "s", "".($WA_DFP_UploadStatus["WA_UploadResult2"]["WA_UploadResult2_1"]["serverFileName"]) ."", "WA_IGNORE");

You can get the correct code from the bindings if you choose the file upload field and the "server file name" value.

Sign in to reply to this post
loading

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...