close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

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

Thread began 6/13/2015 4:32 am by administration282761 | Last modified 6/15/2015 2:29 pm by Ray Borduin | 729 views | 1 replies |

administration282761

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.

Sign in to reply to this post

Ray BorduinWebAssist

You should be binding the value for the insert server behavior from the File Upload settings and the "Server File Name" value. If you get it from the $_FILES array it will have the original file name and not the one the upload renames it to.

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