Want to shorten image url in asp.net My Code in Asp.net is
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(Server.MapPath("images/") + filename);
And It store url in my Database as
C:\Users\A\Documents\Visual Studio 2012\WebSites\WebSite1\images\IMG_20190802_114524.jpg
I want to shorten my image url in Mysql DB
/image/imagename
The Concept of saving file URL in DB is you have to save relative path only. In your case
let spouse:
C:\Users\A\Documents\Visual Studio 2012\WebSites\WebSite1\images\IMG_20190802_114524.jpg
This part is same for all images so why you are saving this in db make a constant and asign this path.
C:\Users\A\Documents\Visual Studio 2012\WebSites\WebSite1\images\
Now you have to save only file name in db.
IMG_20190802_114524.jpg
So when you want to access image concatenate constant value and file name and you get image.
Hope this'll help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.