Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear Friends

I am using localhost and I have written a function which uploads the image file to images directory and then store its address to the database.

I have to upload about 1000 images before launching my site to remote server. But the problem is if I upload these images while working on localhost then all the images have the address of localhost. But When I will launch my site to any hosting server, how I will access these images because they all have the address of localhost in database.

For example:
when i upload image working on local host its address will be like that
"http://localhost/images/file.jpg"


How I will access this file, When I will launch my web to actual hosting server.

Plz Help me in this situation.
Posted

1 solution

This doesn't make any sense. Images do not have addesses. If you stored the image in the database, it doesn't matter where they came from, unless you stored the "localhost" address in your database too for some stupid reason.

Or, if you only stored the path to the image FILES on disk, now you've got a problem. You should not have sotred the address portion of the path to the file. You should have stored just the relative path to the location of the file on disk. Then, when retrieving the image file, you build the fully qualifed path using known directory paths and the relative path stored in the database.
 
Share this answer
 
Comments
rashidfarooq 1-Apr-11 11:21am    
Thanks for answering me. I am not storing my images to database. I am just storing their path to database.
I think you are right. I should store only the relative path to my database.
Thanks a lot for helping me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900