Web Connection
AddPostFile - Name of the file
Gravatar is a globally recognized avatar based on your email address. AddPostFile - Name of the file
  Vincent H.
  All
  Jan 28, 2025 @ 02:38am

Hi Rick,

I have a problem with AddPostFile

nHTTPPostMode = 2
AddPostFile ("file", m.File .T.)

My file name is not converted to UTF-8 and if I convert it with strconv (m.File, 9), addPostFile does not find it ("THIS.oPostStream.Write( FILETOSTR(FULLPATH(tcValue)) )")

Thanks in advance

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Rick Strahl
  Vincent H.
  Jan 28, 2025 @ 08:55am

The filename can't be Utf-8 encoded - it has to be an actual match to what's on disk. If you can't represent it with your active character set in VFP, that's a problem at the FoxPro level that I'm not sure you can work around.

What's the concern here exactly?

I am wondering now if there might have to be some additional encoding at the HTTP header level when the filename (just the actual name, not the path) gets embedded into mime header.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Vincent H.
  Rick Strahl
  Jan 28, 2025 @ 09:53pm

Thank you for your answer.

In the naming of my files, I use French accented characters.

Fortunately, I discovered that there was an optional tag in the application allowing to enter the name of the file (in UTF-8 of course)

I take this opportunity to tell you that in another application, I was able to use the 4th parameter (tcContentType), very useful !

Vincent

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Rick Strahl
  Vincent H.
  Jan 29, 2025 @ 03:06pm

Hmmm... can't you use the file name as is? What happens if you do?

If anything the filename probably needs to be UrlEncoded not UTF8 encoded.

? Urlencode("café.txt")
// caf%E9.txt

I'll have to check up on this. If it has to be encoded this should probably be done automatically as part of the upload encoding.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Vincent H.
  Rick Strahl
  Jan 29, 2025 @ 09:52pm

Unfortunately no, the name of the uploaded file must be in utf-8 format or it will be rejected

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Tore Bleken
  Vincent H.
  Jan 29, 2025 @ 10:40pm

Please pardon me for jumping in...
I suggest that you show us some file names which are rejected.

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Vincent H.
  Tore Bleken
  Jan 29, 2025 @ 10:50pm

No problem, thanks. For example:

loi alur - remise en mains propres des documents de la copropriété - aaa_xxxxxxxxxx[1].pdf

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Rick Strahl
  Vincent H.
  Jan 30, 2025 @ 11:35am

So I'm checking into this and it looks to me that browsers are in fact encoding filenames to UTF-8 as you mention.

I've fixed this in wwHttp so now the filenames for oHttp.AddFile() will automatically Utf-8 encode the filename.

This also needs a fix on the Web Connection end for wwRequest.GetMultipartFile() and wwRequest.GetMultipartFiles() both of which were not decoding the UTF-8 encoding of the file.

It'll be in the next release.

Thanks for the heads up. Amazing we've not run into this before.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: AddPostFile - Name of the file
  Vincent H.
  Rick Strahl
  Jan 30, 2025 @ 09:43pm

Great !

Thanks Rick for always being so reactive

Vincent

© 1996-2025