473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I change "\" to "/" in a file address from user input?

Hi,

Here's the problem. I am trying to allow the user to change a page background to an image file on their computer. The input box is already a 'type=file', however it uses the character "\" when it needs to be "/". Otherwise it errors and the background is blank/white. I used 'type=file' to make it easier for the user to select and input the image file location & filename, of course.

In short, I need to filter out "\" in a variable string, making it "/". I'm mainly wanting it to work on IE6/IE7, but if there is a code that will work on other browsers, that's preferred.

I know nothing about using other program languages, so please don't suggest any other language than javascript. I would like to understand my own program content for future use. :) Not to mention, my host may not allow me to use others.

I've tried, and gave up on, sorting the string using indexOf() and using replace(). Neither works with the "\" and "/" characters and errors. I can get them to work on (most) other characters, but it seems to fart out on this specific one!

I'd appreciate all help I can get. I've turned up nothing from fiddling with it myself and doing many internet searches to find a working code.

Thanks in advance. Hopefully this is enough information.
Oct 4 '07 #1
2 1277
Logician
210 100+
Hi,

Here's the problem. I am trying to allow the user to change a page background to an image file on their computer. The input box is already a 'type=file', however it uses the character "\" when it needs to be "/".
Expand|Select|Wrap|Line Numbers
  1. str=str.replace(/\\/g,'/');
Oct 4 '07 #2
Expand|Select|Wrap|Line Numbers
  1. str=str.replace(/\\/g,'/');
Thank you so vary much! When I was trying to do it, I was 1 character away from what you listed! That character was the second '\'. I feel like such a fool! Again, Thanks alot! :)) It works great now!
Oct 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave Lambert | last post by:
Hi, hope someone can help, I would like to change permissions on a folder and wondered if it is possible as part of an automated install, the reason being we have created an install for an asp.net...
7
by: F. Michael Miller | last post by:
I have a db with Access front end, sql back, linked tables. I need to be able to change input masks at the table level in code. Any ideas? Thanks!
4
by: Simon Niederberger | last post by:
Hi all I need to write a script which overwrites certain .php files in the current directory. Running as www user, I get a Permission denied on fopen. Obviously, I could CHMOD all files to allow...
0
by: landesjoe | last post by:
Hi, Here's the problem: We have an app that we open by default for the user logged into the Windows box on a Windows Domain (using active directory). Let's say that's "Hans". That works great,...
2
by: James Reid | last post by:
I'm looking for the source code for a DOS command line c/c++ program that can change file associations. In other words it can cause any version of Windows to associate a particular .exe file with a...
13
by: James Reid | last post by:
I'm looking for the source code for a DOS command line c/c++ program that can change file associations. In other words it can cause any version of Windows to associate a particular .exe file with a...
0
by: junis | last post by:
Dear All, if i want to change permission in Ms Access, i just follow this step 1. click "Tool" -> "Security" -> "User Group Permissions" 2. I choose User in Box User/Group Name then select...
1
by: Oliver | last post by:
Newbie, looking at DB2 on AS400 iSeries, on Windows network. I have read that users are authenticated at the OS level, not at the database level. How do I make it possible for users to change...
4
by: bluethunder | last post by:
Hello guys, I made a system and my professor suggested to put a log-off/change user button where can easily change the user without closing the whole system like the concept of log-off in the...
3
oll3i
by: oll3i | last post by:
how do I change input font color? thank You
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.