How to upload an attachment file to the nav server

I don’t know if nav can do this? I want to upload an file (may be not an .txt or .xml) from classic client or rtc to the nav server and save it to some place on the server.

Any suggestion will be in warm appreciate.

Hi Gary,

Take a look at Walkthrough: Uploading a File from a Client to Microsoft Dynamics NAV Server on msdn.

Cheers,

Dave.

Hi Gaspode
Thanks for you rely。
I have read this article, But If I want to update some rar files to the nav server,And just save the path to nav database. How to do this ? If I can use the same method with the article’s?

Thanks for your reply again.

woo…, Why does my reply message in a so terrible order ? If i send the message by “quick reply”?

Thanks Gaspode.

I have tried to use Upload function, But it seems not worked. The file was not been saved.

Anybody’s suggestion will be in warm appreciate.

Hi Gary,

yes you’re right that walkthrough is terrible. I thought it would answer the question from skim reading through it but after reading it more carefully I see that it doesn’t really give you what you are after.

I have used the File.Upload successfully a number of times, maybe you could post some code that you have tried that does not work as it’s a bit hard to help without specifics.

You could try creating a file on the server (just use the normal FILE commands as this will execute on the server), opening an instream into the file, using UploadIntoStream and then closing the file. I’m pretty sure that would work. I think the only downside to this is you cannot do it without popping the FileRequester dialog to select the file you are going to upload unless you are uploading from a temp path. There is something in there that tells the system that if the from location is the temporary file path, the file requester is not shown. It sounds as though you are quite happy for the file requester so that should be OK.

Cheers,

Dave.

Thanks Gaspode.

If I made a wrong understanding of “upload function” ? Is it right about that the upload function just can be run on the rtc client can not run on the classic client ? I just tried the code running on the rtc, I found it is ok,But on classic client ,it is not ok.

Hoping for you reply.

Merry Christmas Eve.

Hi Gary,

that’s right. The upload and uploadfromstream, download, downloadfromstream functions are specifically for transferring files between the RoleTailored client and the NAV Server.

If you need to move a file on to a server in a classic client, you just need to specify a location that is accesible to the user running the client (i.e. unc file path or a mapped drive). You can then use the regular file.move or copy commands to put the file where you want it.

If you are using the RoleTailored client, you cannot do this because the code executes on the Server so if a user makes reference to c:\copyme.txt as the file they wish to upload, the server does not have that file on it’s c: drive, hence you must upload the file to the server first.

Cheers,

Dave.