Using UPLOADINTOSTREAM silently in Dynamics NAV 2013

I’m trying to get a PDF uploaded into the Attachment table silently.

First I have created a PDF file which is stored on my client (C:\Users\MyUserAccount\AppData\Local\Temp\MyApp\C3501751-6FB9-44B9-98EF-44965CB62426\Quote J00090.pdf). Then I call my function to upload the file.

UploadResult := UPLOADINTOSTREAM('','<TEMP>','',FileName,NewInStream);

But I’m getting this error:
‘Could not find file ‘C:\Users\MyUserAccount\AppData\Local\Temp\Microsoft Dynamics NAV\25388\Job Quote J00090.pdf’.’

Must I somehow create this server side file, or shouldn’t the UPLOADINTOSTREAM not do this automatically? Or what is wrong? If I’m running this without the “magicpath” then it works fine, but the user is prompted for the filename.

I found the solution in the NAV Team Blog.

The problem was that the location of my client file was not in the location the (magicpath) expected it to be for it to work. So I had to find my magicpath location and copy my file here first, before I could use the silent mode.