Upload file by coding

Answered
0
0

Hi, is it possible to upload a client file to the server by coding? The upload control, saved the client file to the server, before saving other data. In traditional ASP development, we just take the client file from the browser, and while saving (by clicking the save button), we save the given data along with the file attached.

I need just like this. Just get a filename with path (as attachment). When the user clicks the save button, then we move the file from the client to the server along with the saving operation. I didn’t find, this kind of scenario in the entire forum.

If anybody guides me, it would be useful to my project.

Thanks a lot in anticipation.

  • You must to post comments
Best Answer
0
0

Hi Thameem

I attach your sample modified to upload any type of file (text or binary) one level up of bin directory

Also considere validating the target directory each time the app write the file, becaouse another process could delete the upload directory between file uploads

Regards and happy coding

 

Attachment
  • Thameem Ansari
    Thanks a lot for your great support. It’s working like a charm
  • You must to post comments
0
0

You are writing into /bin causing IIS or IIS Express to reload the application. This is standard behavior, not related to Wisej. Use Application.MapPath() or write somewhere else outside of /bin.

  • Thameem Ansari
    Thank you so much for the explanation. I modified the code and it is working fine.
  • You must to post comments
1
0

In this upload test project, after the “uploaded event” is fired, the window goes to an ‘offline’ state (it shows the message(popup), at the top of the browser, that it is offline), then immediately the window is refreshed. If you run the project, you can see it. Could you please help me, how to avoid the refresh? FYI: the version I installed is 2.2.48

Herewith I attached the project and the 3 images.

  • You must to post comments
0
0

I think you are referring to the Submit action in an HTML page. Wisej is a Single Page Application (SPA) system. There is no submit or post. It’s all ajax. The file is transferred when you pick it (or you can drag & drop it) and it’s up to you to store it somewhere (memory, temp, anywhere) and then do with it whatever the app needs to do. There are several events that give you full control.

There is no auto refresh in Wisej.

  • Thameem Ansari
    Thanks for the solution. BUT THE WINDOW IS REFRESHED AFTER THE “UPLOADED” EVENT IS FIRED. So only I attached the window1.zip in my earlier answer. Herewith, under “post answer” I attached the sample upload project, which I tested. Please run the project, then you can see it. Suppose, if we have more than one upload control, then if it is refreshed every time, then really the window (or the page) is useless. FYI: the version is 2.2.48
  • You must to post comments
0
0

Hi, herewith I have attached two image files. In the first image, there is one Upload Field and 3 other input fields (text boxes). What I want is. here the user selects a file (client-side) in the upload filed, and he can enter any data on the 3 fields. While saving the form data, by hitting the save button, the textboxes’ data are moved to the database and finally, the client-side file would move to the server.

But, as per the second image, the client-side file is moved to the server in the “uploaded event”, by using the “SaveAs” function, that is before saving the form data. So, instead of doing it in the “uploaded event”, I want to do the same operation in the save button’s click event (while saving along with other form data)

Is it possible?

And, after the “uploaded event” is fired, the form is auto-refreshed and the data in the text boxes are reset. How to avoid the auto-refresh, after the “upload event” is fired?

  • You must to post comments
0
0

Wisej doesn’t save anything on the server automatically. It’s always done by your code and it’s the same ASP.NET classes. If you want to send a sample showing what you need or the traditional ASP sample that does what you need we can help you further.

  • Thameem Ansari
    Since unable to attach files, I posted my reply under the “Post Answer” form.
  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.