且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

上传图片并将URL保存在数据库中.

更新时间:2023-02-15 12:51:47

使用以下链接上传图片

http://hemantrautela.blogspot.in/2012/03/image- resize-in-aspnet-with-cnet.html [ ^ ]

和url,您可以为数据库(images/image.jpg)进行更改
upload image by using below link

http://hemantrautela.blogspot.in/2012/03/image-resize-in-aspnet-with-cnet.html[^]

and url you can change it for database (images/image.jpg)


我建​​议您不要将URL存储在数据库中-因为URL可能会发生变化(如您的示例所示,如果此站点已发布,则URL将不再是localhost.)

相反,如果将文件存储在名为上传"的文件夹中,则可以安全地将文件名存储在数据库中,然后,如果需要检索文件或提供其URL,则可以使用已知的文件来构建URL.数据库中的文件夹名称和文件名

如果文件夹可能会更改,则只需将文件夹名称和文件名存储在数据库中

您始终可以将URL提供为〜\ Uploads \ abc.jpeg
I would suggest that you don''t want to store the URL in the database - as the URL may change (as in your example, if this site was published, the URL would no longer be localhost.)

Instead, if you store the files in a folder called ''Uploads'' you can safely just store the file name in the database, then if you need to retrieve the file, or provide its URL, you can build the URL using the known folder name and the filename from the database

If the folder may change, then just store the folder name and file name in the database

You can always provide the URL as ~\Uploads\abc.jpeg