close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

How to replace or rename image file name containing umluats or accents on file upload

Thread began 6/13/2015 1:32 am by astrostrom | Last modified 6/15/2015 11:29 am by astrostrom | 2225 views | 1 replies

astrostrom

How to replace or rename image file name containing umluats or accents on file upload

Hello, as I am based in Europe I have a problem that people using our website and wishing to upload an image often have an umlaut, an accent or an empty space in their image file name such as: märz.jpg or le hôtel.jpg.

While the file will upload and the name will be inserted into the DB, the image will not display due to this problem.

In another thread I am asking about how to rename both the uploaded file and the text that is inserted into the DB with a number.

Another approach would be to remove the offending characters as discussed in the thread (Rejecting File Names with Wrong Characters - 11/26/2012) where Jason Byrnes wrote:

the following example will remove the & \ ' character, you can add others to the array:
<?php
if(isset($_FILES)) {
foreach($_FILES as $k => $v) {
$_FILES[$k]["name"] = str_replace(array("&","\\","'"),"",$_FILES[$k]["name"]);
}
}
?>

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

Taking this approach I have added the following code to the top of mage page:

----------
<?php
if(isset($_FILES)) {
foreach($_FILES as $k => $v) {
$_FILES[$k]["exhibition_image"] = str_replace(array("ä","ö","ü","é","à","é","ò","ô"," ","&","\\","'"),"",$_FILES[$k]["exhibition_image"]);
}
}
?>

------------
From the upload form:

<input name="exhibition_image" type="file" id="exhibition_image">

----------

From the upload Server behavior:

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

---------

Unfortunately, both the uploaded image file as well as the file name text inserted into the DB still have the umlaut.

I am using the WA MySqli extension and WA DataBridge File Manipulation feature.

Any suggestions?
Thanks for your help.

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