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

How to rename file on upload

Thread began 2/07/2020 2:26 pm by LWat85283715 | Last modified 2/11/2020 1:01 pm by Ray Borduin | 32 views | 3 replies |

LWat85283715

How to rename file on upload

I am trying to rename a file upon upload. The name will be some data from a recordsets separated by underscores. For some reason the name isn't coming out correctly. Here is my code:

<?php
$applicants = new WA_MySQLi_RS("applicants",$cori,1);
$applicants->setQuery("SELECT * FROM applicants WHERE applicantID = ?");
$applicants->bindParam("i", "".(isset($_GET['applicantID'])?$_GET['applicantID']:"") ."", "-1"); //colname
$applicants->execute();?>
<?php
$fname= $applicants->getColumnVal("fname");
$lname=$applicants->getColumnVal("lname");
$dob=$applicants->getColumnVal("dob");
$ssn=$applicants->getColumnVal("ssn");
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "verification_files",
'FileName' => "".$lname ."_".$fname ."_".$dob ."_".$ssn ."",
'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", "id_image", "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
}
?>
<?php
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
$InsertQuery = new WA_MySQLi_Query($cori);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "verifier";
$InsertQuery->bindColumn("applicantID", "i", "".$_GET['applicantID'] ."", "WA_DEFAULT");
$InsertQuery->bindColumn("staffID", "i", "".((isset($_POST["staffID"]))?$_POST["staffID"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("verificationID", "s", "".((isset($_POST["status"]))?$_POST["status"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("verification_type", "s", "".((isset($_POST["verification_type"]))?$_POST["verification_type"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("id_image", "s", "".($WA_DFP_UploadStatus["WA_UploadResult1"]["WA_UploadResult1_1"]["serverFileName"]) ."", "WA_IGNORE");
$InsertQuery->bindColumn("staff_signature", "s", "".((isset($_POST["staff_signature"]))?$_POST["staff_signature"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("verification_date", "t", "".((isset($_POST["verification_date"]))?$_POST["verification_date"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "email_verified.php?applicantID=".$_GET['applicantID'] ."";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

What is the result with this code? It is hard to tell what might be wrong just looking at the code directly. Please attach the page so I can test to see why it doesn't work. It looks like it would work to me.

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

LWat85283715

It changes the filename to 2009_123456.png and enters the name in the database but, no file is downloaded. The file name should be changed to the fname_lname_dob_ssn.pdf. Which in this case is Lisa_Waters_2009_11_20_123456. Attached is the file. Thanks

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

LWat85283715

I got it to work. The issue was the dob wasn't stored as a date and was causing it to fail. All fixed. Thanks so much.

Sign in to reply to this post

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