close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to create a unique image file name containing umlauts or accents on upload?

Thread began 6/12/2015 9:04 am by astrostrom | Last modified 6/19/2015 2:14 am by Ray Borduin | 3619 views | 8 replies |

astrostrom

How to create a unique image file name containing umlauts or accents on upload?

The Problem:
Image file names that contain umlauts, accents or empty spaces do not display properly on the server once they are uploaded.
examples: märz.jpg, hôtel.jpg or march photo.jpg, hôtel à paris.jpg

Needed Solution:
I would like to be able to rename the uploaded image file with a unique file name that also gets inserted into the DB.
Example "märz.jpg" or "march photo.jpg" would be renamed to something like: "18732947.jpg" which also be inserted into the DB

On page 2 of the Digital File Pro Upload Wizard instructions it states:

Note: You may want to rename the file using a different naming convention by either: specifying a name directly, using the browse function, retrieving a name using available data bindings, or specifying server-side code to develop a dynamic naming convention.

Is this possible using any of the options above and, if so are there any examples / tutorials on how to do this?

Thanks

Sign in to reply to this post

Ray BorduinWebAssist

You can specify a new file name on the second screen of the file upload server behavior. You could set it to the session_id() value to make it use a random number. (screen shot attached)

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

astrostrom

Dear Ray

Thanks for the quick reply. The screenshot is a bit too small to see clearly.
Perhaps you could post it again as a larger image.

I selected the session when I clicked on Lighting bolt.
<?php echo $_SESSION['']; ?>

But this gave me an error when I loaded the page.

Then I tried to get the session id which I am using to connect the form.
<?php echo $_SESSION['address_id']; ?>
-------------

<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../../exhibitions/",
'FileName' => "".$_SESSION['address_id'] ."",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "205",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>

-------------------

But this does not seem to change anything but I am not sure it is the right selection.
The original image name with the umlaut is still being inserted into the DB and the image file is uploaded to the upload folder - also with the original image name including the umlaut. I would like to be able to change (replace) both the file name with the umlaut and that which is inserted into the DB.

(BTW - I am using the mySQLi extension to generate the recordset and to manage the Insert Record)

Sign in to reply to this post

Ray BorduinWebAssist

Try:

'FileName' => "". session_id() ."",

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

astrostrom

Dear Ray

Thanks again for your reply. Your suggestion:
.
'FileName' => "". session_id() ."",

succeeded in renaming the uploaded image file (also with increments) into the image folder, however I have not been able to get the corresponding image name into the DB.
Obviously I need change something in the bind column but so far all my variations either give me the original file name or write a blank

Insert Record:

$InsertQuery->bindColumn("exhibition_image", "s", "".((isset($_FILES["exhibition_image"]))?$_FILES["exhibition_image"]["name"]:"") ."", "WA_DEFAULT");


File Manipulation:

// WA_UploadResult1_1 Start
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../../exhibitions/",
'FileName' => "". session_id() ."",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "205",
'ResizeHeight' => "",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "exhibition_image", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult1_Params);
}
?>


Upload Form:

<td><input name="exhibition_image" type="file" id="exhibition_image" value=""></td>


I can see the session_id with this code:
<?php echo session_id()?>
which I could put into the form if necessary.

It would be great to accomplish this last step.
Attached is an image file with umlauts,
Thanks for your help.

Sign in to reply to this post

Ray BorduinWebAssist

There are separate bindings added by the file upload server behavior that you should use instead of the form field for binding the inserted value to the database.

If you use that the result would be:
$InsertQuery->bindColumn("exhibition_image", "s", "".($WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]) ."", "WA_DEFAULT");

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

astrostrom

Greetings again and thanks for your input.

However, as before, I am still not able to write the name of the file into the DB. I get a "blank" entry.

When I click on the File Manipulation SB Interface - I get the following error message.
"It appears that one of your server-side values is improperly coded. Please click this interface for inconsistencies."

Attached is the second page screen of the wizard.

Here is my code:


<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$InsertQuery = new WA_MySQLi_Query($mysqli2);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "agenda_exhibition";
$InsertQuery->bindColumn("address_id", "i", "".((isset($_POST["address_id"]))?$_POST["address_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("exhibition_image", "s", "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."", "WA_DEFAULT");
$InsertQuery->bindColumn("exhibition_title", "s", "".((isset($_POST["exhibition_title"]))?$_POST["exhibition_title"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("exhibition_url", "s", "".((isset($_POST["exhibition_url"]))?$_POST["exhibition_url"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("exhibition_lead", "s", "".((isset($_POST["exhibition_lead"]))?$_POST["exhibition_lead"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("exhibition_init", "t", "".((isset($_POST["exhibition_init"]))?$_POST["exhibition_init"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("exhibition_exp", "t", "".((isset($_POST["exhibition_end"]))?$_POST["exhibition_end"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "agenda_admin.php";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

---

<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../../exhibitions/",
'FileName' => "". session_id() ."",
'DefaultFileName' => "",
'ResizeType' => "2",
'ResizeWidth' => "205",
'ResizeHeight' => "",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "exhibition_image", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult1_Params);
}
?>

----

Should I open a server ticket to troubleshoot this?

Best regards

Sign in to reply to this post

Ray BorduinWebAssist

Move the insert record code below the file upload code. I think it is just an issue with the position of the code on the page.

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

astrostrom

Dear Ray

Yes, Yes, Yes...That did it!

Thank you for your help.

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