I’m trying to upload a file to the server (.net 4.8), I’ve read all the forum posts and examples but I haven’t figured out how to do it yet. I tried with the Upload control and with OpenfileDialog. In the first I can’t find FileName (which I use in Asp.net), in the second if I understand correctly I should use Powershell but I can’t find the references.
Any complete examples, if possible?
This is my code in Asp.Net:
string cFilename = FileUpload1.FileName.Trim();
byte[] aFile = FileUpload1.FileBytes;
EDIT:
I try this:
private void upload1_Uploaded(object sender, UploadedEventArgs e)
{
var oFile = e.Files[0];
oFile.SaveAs(cPath + “myfile.txt”);
}
The file is saved but the app restarts.
SECOND EDIT:
I tried this too, but the application restarts.
private void upload1_Uploaded(object sender, UploadedEventArgs e)
{
var oFile = e.Files[0];
Stream oStream = oFile.InputStream;
oStream.Position = 0;
byte[] buffer = new byte[16 * 1024];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = oStream.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
byte[] aByte = ms.ToArray();
File.WriteAllBytes(Leo.cPath + “test.txt”, aByte);
}
}
Hi Francesco,
you’re getting the filename(s) in e.Files of the Uploaded Event.
Sample
https://github.com/iceteagroup/wisej-examples/tree/3.5/UploadFiles
Documentation
https://docs.wisej.com/api/wisej.web/content/upload
Best regards
Frank
Please login first to submit.