Uploading image to a server and saving its path in database using Classic ASP - asp-classic

I am quite new to ASP classic and have been assigned a task related to image uploading. What i have to do is that i need to upload the image file on server and then save its corresponding path in database. How to achieve this. Any help will be much appreciated.

Have a look at http://blog.offbeatmammal.com/post/2005/11/19/Upload-and-resize-and-image-in-ASPNET.aspx for a sample that will upload a file to the server. Once uploaded you can take the assigned filename and store that in your DB table

Related

How to auto-upload files to a server from a local directory in ASP.NET

I am trying to upload an image from my computer to hosting server using ASP.NET code, but I don't know if it's possible.
If it is, can you help me?
Sure it's possible. Read up on how the FileUpload class works: https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.fileupload?view=netframework-4.8
It won't be an automatic upload like you ask in the title, but you will be able to send files thru the browser and wherever you want them to go.

Saving images from a website and accessing it from another website

I have created a website let's name it a.com. Now in this website (a.com) the users can upload an image that gets saved to a folder on remote server and the path is getting saved to database.
There is a second website (b.com) which has been hosted on the same server where the image needs to be retrieved.
Can we do this? If yes then please suggest some solution
Language Used = Asp.net 4.0 C#
Backend = SQL2008
It cane be done, if both website can access the remote folder. You need to use something like System.Net.WebClient to download image from remote server.
Since your using SQL and .Net im going to assume your using IIS aswell,
Creating a Virtual directory is probably your best bet, Easy to setup, easy to manage and Extremely handy to understand (if not vital)
http://www.iis.net/learn/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis
This is assuming you want to display the image in b.com, if you simply want to retrieve it you can do so by retrieving the path and using the image in any other way, you may need to set permissions on the image folder.
first of all both sites should use the same database to share information about images.
If I understand correctly b.com and the files are on the same server. If so put folder's virtual path to configuration.
After that, check database for new records. If found one, parse the name of the file and find it on the server.
As an example you get an image on a.com and insert it on database as
name="image.jpg"
b.com checks database for new records and finds image.jpg.
b.com reads configuration and finds
path="http://c.com/"
combines path and imagename
fulllink="http://c.com/image.jpg"

ASP.NET File Upload without storing on the server

I have an ASP.NET 2 application and would like users to upload a file to be processed immediately. The file never needs to be used again, so I don't care to store it on the server as a file somewhere, which hopefully will make it more secure on our end.
Basically, they upload an excel file and I process it and display some results. I do not care to save that excel file for later.
How can I do this?
You can hold the file contents in a MemoryStream.
This will ensure it is not saved to disk.
See What is the best practice for storing a file upload to a MemoryStream (C#)? for details.

How to fetch and show image path from database into file upload control

I have saved images using File upload control in asp.net now i want fetch its path from database and display into file upload control please help me out
You will have to display image in image control using Server.MapPath("~/SomeDir/image.jpg")
Why would you want the server file path to appear in the file upload control? If you think about it, it makes no sense. The path that comes back would be relevant to the server, not the user so chances are the location would not exist on the users machine. If you really need to display the server location for any reason just stick it in a label.

Asp.Net, upload picture with VS2008 local web server

Users of my web site will be able to upload a picture. This picture will land in /images/folder/picture.jpg. The question I have is: When running under VS2008, a form will insert a full row in a database column (sql server)and the picture will be uploaded to the folder. The result page will show the image. But when running the web server again later, the database will be ok but the image won't be there anymore since I guess that the local server each timer starts freshly with no content in the folder. I am new to uploading so I am wondering how you do to test this kind of thing.
Also, must the folder for the images be under /Content ? I am not sure where to put it and how it will transition when running under IIS ?
Thx
The ASP.NET development server does not clear the directory each time it starts. Have you verified the files are actually being written where you think they are? Seems like you've probably got some path issues and the files are possibly being written to the ASP.NET Temporary Files folder which may change from instance to instance.
I've have to test this with my local server to see exactly what it's doing with regard to the image that's being uploaded locally... but one thought is that instead of storing the picture on the file system, store it in the database itself.

Resources