File upload successful but csv file type set to binary

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
mperez
New User
Posts: 9
Joined: Tue Sep 10, 2019 10:24 am
First Name: Michael
Last Name: Perez
Company Name: Manhattan Life Insurance
Contact:

File upload successful but csv file type set to binary

Post by mperez »

I am uploading a csv file to an IFS folder using the file upload widget, and the upload completes successfully, but when a separate RPG program tries to open the uploaded file using the iSeries fopen() function, it returns NULL if opening in text mode, using mode 'r'. If I change the mode to binary ('rb'), it will successfully open the file. Is there a file attribute I can set/change in the RPG (or widget) so that it remains as a text file in the IFS folder?

file upload widget prop:
allowed type: text/csv
allowed type 2: application/vnd.ms-excel

RPG program: fopen() implementation in an included procedure that calls ExtProc('_C_IFS_fopen')

file = fopen(%trim(CsvFilePath) : 'r');
if (file = *NULL);
file = fopen(%trim(CsvFilePath) : 'rb');
if (file = *NULL);
Exsr $Exit;
endif;
endif;

Thanks,
Michael
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: File upload successful but csv file type set to binary

Post by Scott Klement »

The fact that adding 'b' solves the problem makes me think that the file has been marked with the wrong CCSID -- but this is just a guess since you didn't post the error message. (Indeed, it doesn't even look like you've retrieved the error in your code?)
mperez
New User
Posts: 9
Joined: Tue Sep 10, 2019 10:24 am
First Name: Michael
Last Name: Perez
Company Name: Manhattan Life Insurance
Contact:

Re: File upload successful but csv file type set to binary

Post by mperez »

The fopen function doesn't return an error code/msg from what I can tell, it only sets the file pointer to null if it doesn't open the file. I agree, I think it's the CCSID. The RPG code does open the file, but I'll review setting the CCSID on the file. Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests