It's going to depend on how you've initialized your
exportPath
variable, which you haven't shown.
However, based on the code you
have shown, I suspect you're not handling the upload properly.
The name of the uploaded file will be the path, or more often just the filename, of the file
on the client. Your code is running
on the server. You cannot simply open the specified path on the server and expect to read the file from the client!
It might
appear to work when you're debugging in Visual Studio. But that's only because, in that specific case, the server and the client are the same computer. Once you deploy your code to a real server, you will either get a
FileNotFoundException
, or in the extremely unlikely case that the file already exists in the same path on the server, you will be reading the wrong file.
You will also open up a security vulnerability - an attacker can pass the path of any file on your server and have it send in the response. They could use that to read your
web.config
or
appSettings.json
files, which could reveal information you don't want them to see. They could use it to download your application binaries, which they could then decompile to see your source code. They may even be able to download your database files.
The file upload name is for information only, and should not be trusted. You need to read the uploaded file contents from the
IFormFile
instance's stream.
Upload files in ASP.NET Core | Microsoft Docs[
^]
IFormFile Interface (Microsoft.AspNetCore.Http) | Microsoft Docs[
^]