You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

allow only csv file to be uploaded.

2 replies [Last post]
Guest's picture

Hi ,

I want only .csv file to be uploaded from addattachment function. If the user tries to upload .txt or any file other then .csv i need to display error message. Addattachment is working fine but it is also allowing oher ext files to be uploaded. can anybody help ?

RD's picture
RD (not verified)
Re: allow only csv file to be uploaded.

You can use FileType parameter for the function AddAttachment. But the FileType parameter is only a suggestion. Specifying it does not enforce specific file types. If you do not want specific file types (such as .exe or .bat) you must write PeopleCode to discern the name and file type of the attached file and delete it.

You may not be able to filter files by file type due to browser limitations. You may have to write your own PeopleCode to do this filtering before you call the browser.

When the end user views attachments using the ViewAttachment function, some browsers treat documents as HTML regardless of file extension, and thus execute embedded Java script. You may want to write a PeopleCode program to only allow specific file extensions to be viewed. Refer People Books Home > PeopleBooks > Enterprise PeopleTools 8.48 PeopleBook: PeopleCode Language Reference > PeopleCode Built-in Functions

If you want to restrict entirely a type of files like .exe or .bat, which I have done in some client's place is comment the web.xml file in $PS_HOME/webserv/domain/applications/peoplesoft/PORTAL/WEB-INF folder like the one below:

But, remember this will work for all functions including GetAttachment, PutAttachment. so take care while commenting this.

Best of luck.

Guest's picture
Guest (not verified)
Re: allow only csv file to be uploaded.

just use the right() function to read the last 4 characters & place an if else condition.