Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy and rename file

Status
Not open for further replies.

hepower

Technical User
May 16, 2001
10
US
Could someone tell me how to copy a file to another name and directory in html or whatever? I am using a shareware/freeware program that has the name of a file embedded somewhere in the code. I can manually replace that file but what I want to do is let a user pick a choice then move the cooresponding choice to that file name. I can easily set up different directories and have links point to each but I want to try and cut down on the duplication.
 
A class uses "pic1". I also want to use pic2,pic3,etc... but they have to be renamed to "pic1" in order for the class to work. They (pic2,pic3,etc...) are stored in another directory. How do I copy pic2 to pic1 in the directory that pic1 resides? Overwriting pic1 is no problem. These will be chosen by links (hopefully) or a drop down list in an html file.
 
well...I'm still not completly sure what you want to do..You want to have a bunch of imgs and when you need them, you need to change the name to "pic1"..right?

if so then use this bit of jscript:

pic1.src = "pic1.gif"
pic1.src = "pic2.gif"

this will name the picture "pic1" when you do this code the old picture (named pic1) will be replaced with a new picture (the new pic1) -Greg :-Q
 
Yes that is what I want. Would you mind expanding on that a little more? Thank you
 
when you name your imgs..do it like this (between javascript tags):

Code:
if (document.images) {

pic1 = new Image
pic2 = new Image  (do this for all of your pics)

pic1.src = "pic1.gif"
pic2.src = "pic2.gif" (do this for all imgs so they preload)

}

then to change an image name, do it like this:

(this will take pic2.gif and name it pic1, again do this in javascript tags)

pic1.src = pic2.src

(now pic2.gif is named pic1)

hope that helps

-Greg :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top