Upload file to server using class dll - asp.net

It is fairly easy to upload a file using web form. But I need to accomplish this through DLL.
I have classic ASP page with file upload form and I need to create an object that handles the uploaded file from customer and save the file to the server. What would be the best way to approach this? I have been digging and came across Web.HttpPostedFile and HttpWebRequest. but I don't know which route to take.
Also, I am a bit confused about how to pass the uploaded file to DLL so my class can upload and manipulate the file. is there any sample code for this?
Thanks for any help or advice.

This question doesn't make much sense, as you kind of asking "I have old car's parts and I need to assemble one by using a wheel". What? That doesn't make sense.
A dll is a container for some code. You do not use a container per se to upload a file. You should search for "classic asp upload file sample", find a solution, give it a try and come back with a specific problem.
I also noticed HTTPS tag, the idea with S, is that you don't care whether it is secure or not from the programming perspective. If you are able to use HTTP, it is trivial to upload files to HTTPS - just change the URL in the UI. The server code itself wouldn't change. What will change is the server hosting configuration, you would have to add certificate details.

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.

ASP.Net Accessing Server Filesystem

I am having trouble accessing information on the server my website it on. As the website was originally programmed with VB.Net, I cannot change the language without having to completely reboot the website. The way the website and server are configured, I can only use ASP.Net and VB.Net.
I am needing to add a section where they can create folders, edit folder names, and upload pictures and text documents on the server through the public website. I tried using parts of the FileIO, Server, and Http that should have worked, but none of them did. Most of my research is about local files and text documents.
I have not been able to find any information that works. Can someone help me? Thank you.
Firstly, creating a virtual directory in ISS mapped to somewhere on your disk would be a good start. This way you have a separate folder for user data in a folder with write access (make sure IIS has write access to the folder!), and the folder is not affected by website deployments.
Secondly, you might need to resolve absolute path for most of the System.IO.File calls. See How to convert a relative path to an absolute path in a Windows application?, just you will need to convert this code to VB.

Publishing ASP.NET files to hosting server and back to local machine.Step by step procedures

I am very new with ASP.NET. I need help understanding the basic procedures of how a developer publishes their site to their hosting server, and then once its compiled and published, how does another developer (someone who does not have the original files), edit some of the code behind files.
For example, Developer A creates a site, uploads it to the server and it works great. We hire a new remote developer (Developer B) and he needs to work on a .cs file, does he need to get a copy of the entire site, to his local machine? if so, does he need to reverse the compiling process to get thos .cs files back?
I am a PHP developer, and since theres no compiling needed, I dont worry about .dlls nor about compiling at all. This would truly help me understand ASP.NET with the hopes that it can also help others like me.
Please help. Thank you in advance.
You do not need a copy of the entire site.
But you need the basic struct of an asp.net site, and what resource you may need to run this individual page.
The minimal basic struct of an asp.net site is this two directories (and the content of them - if any)
App_Code
Bin
together with the web.config that is probably needs some changes to run to the remote developer.
Now some simple logic.
If a page have css, javascript and other files you need them too
If a page need connection to some database, you need that too
In the bin directory you may only give the dlls/libraries that this individual page use (if any)
If the page have links to other pages, or post to other pages, or need ajax call from other pages you need them too.
If some one change some functions on the dll files, you must give the update to the remote developer so he can adapt his code.
After the update he can upload the aspx + cs file on the server.

Access to dynamic images on server

I'm developing a web application in which users uploads images and I'm keeping the location of the uploaded image path on server. For example:
C:\fix_directory\a8531.jpg
In my page, I want to display this image but I couldn't. I've tried many things but couldn't find a way of doing it.. This directory isn't part of my project because it will be always updated.
What is the effective way of overcoming this problem?
Thank you
You could setup a virtual directory (yourweb.com/images) which points to your images, or even a web (cdn.yourweb.com).
You could also write a HTTP handler or a file handler (.ashx) in ASP.NET to serve your images from that location.
Update
I guess the most effective way of overcoming this problem would be to store the uploaded files simply somewhere in your web directory.
Update 2
I'm definitley sure, the most effective way of overcoming this problem is to have a real IIS or a Visual Studio Development Server and not trying to do anything with the Vista Home Basic pseudo IIS which can do nothing.
The simplest way would be to make fix_directory a virtual directory within your project inside of IIS, and access the images that way.
A more complex approach would be to do something in the lines of pulling in your image via a FileStream, and outputting it to your website via a ResponseStream.
A common way this is achieved is by creating a generic handler (.ashx) that's only responsibility is to output your images.

ASP.NET File uploading-dynamic file names

I have a web page where i have an ASP.NET file upload control to upload files from client machine to Server.Now i want to do the uploading n number of times.Ex : I want to upload 100 files from my local pc to server.The 100 file names i can read from an excel file in my program.But is there any way to assign this file to the file upload control ?
No, as a security feature, FilUpload controls do not allow you to set what to download (imagine if you sign on to a website, and it is set to upload a passwords file or something).
Now there is probably another control, or a way to code around this, buut the FileUpload control will not allow it.
I would recommend using the jQuery Multifile Uploader which would take care of a UI (if you need one). And the actual uploads with Free ASP Uploads which takes care of the actual file transfer. Though it sounds like you are tkaing care of the programs programatically, so you can skip the multifule and just work with free asp upload.
You'll have to make your own Flash object or something to accomplish this, the basic HTML/ASP.Net controls won't let you do what you're looking for.
This will require creating some kind of an active or installable control. In order to get around the security hole of doing this, you're ultimately going to have to be able to execute code on the machine to select and upload the file.
And at that point, you're platform specific, so...
I would strongly suggest that instead of trying to have a web site automatically upload files for you, that you make a WinForms utility to accomplish this task and upload the files wherever you need, communicate with the web site over web services, etc.
This is a security restriction, you cant script the file selection of an upload box as it would allow hackers to write scripts to steal files off your computer.
You could use this silverlight upload utility which is my list of "things to use when I get the chance".
It has a nice UI and supports uploading many files at once. I originally tracked it down doing some research for a photography website that we were quoting for but that project fell through.
Anyway the project can be found here:
http://www.michielpost.nl/Silverlight/MultiFileUploader/
It also has full source code included so even if the control's developers abandon it you still have the choice to edit it yourself.

Resources