Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cffile accept WordPerfect documents???

Posted on 2004-10-14
8
Medium Priority
?
318 Views
Last Modified: 2013-12-24
I've got a file upload option that will only accept text files (text/plain, text/richtext, application/rtf, application/wordperfect, application/pdf, application/macwriteii, application/msword).
No matter what I put in for danged WordPerfect, this file type is not accepted.
I've scoured the web and have found no solution.
Hence... I am turning to the experts!
Any insight will be much appreciated.
0
Comment
Question by:jlynn_tn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 7

Accepted Solution

by:
black0ps earned 500 total points
ID: 12313808
This is the info I found on mime type for WordPerfect:
application/wordperfectd       wpd
application/wordperfect        wp wpd
application/wordperfect5.1     wp5
application/wordperfect6.1    wp6
Reference: http://webmaster.iu.edu/mimetypes/

WordPerfect files use extentions wpd,wp,wp5,wp6. Instead of doing a server side validation of the file extension, do a client side javascript or do a server side validation for the extension:

Something like:
<script language="Javascript">
<!--
// x1 = name of form
// x2 = name of image field
// x3 = quote enclosed list of acceptable file types: ".jpg",".jpeg",".gif"
function correctFormats(x1,x2,x3,x4) {
      v2 = document.forms[x1].elements[x2].value.toLowerCase();
      formats = x3.split(",");
      disFormats = "";
      for (j=0;j<formats.length;j++) {
            disFormats = disFormats+"  "+(j+1)+" "+formats[j]+"\r";
      }
      submitform = false;
      if (v2 != '') {
            for (i=0;i<formats.length;i++) {
                  x4 = formats[i];
                  if (v2.indexOf(formats[i]) == -1) {
                        submitform = false;
                  }
                  else {
                        submitform = true;
                        break;
                  }
            }
      }
      else {
            submitform = true;
      }
      if (!submitform) {
            alert("The file you selected for upload was the incorrect format.\r\rAllowed file types include:\r"+disFormats+"Please ensure the file you are uploading is one of these file types.");
            }
      return submitform;
}

//-->
</script>

<cfset formats = "correctFormats('Place','image','.jpg,.jpeg,.gif,.bmp,.png','#Right(Photo.Image,3)#'); return submitform;">
<cfform name="Photo" method="post" action="index.cfm?FuseAction=Details&#Client.URLToken#" enctype="multipart/form-data" onsubmit="#formats#">
 </cfform>
0
 
LVL 1

Expert Comment

by:hiranmaya
ID: 12315880
test2.cfm:

<CFIF isDefined("form.fieldNames")>
<cffile action="upload" filefield="ul_path"       destination= "c:\temp"
                  nameconflict="overwrite">
</cfif>


<form action="test2.cfm" method="post" name="dataForm" enctype="multipart/form-data" id="dataForm">
<input type="file" name="ul_path" id="ul_path">
<input type="submit" value="Submit">
</form>
0
 

Author Comment

by:jlynn_tn
ID: 12320877
OK - blackOps, you recommend client-side validation with javascript with a 'catch' on the server?

I already do validation on the form fields - hadn't thought of also looking at the uploaded file extensions - your javascript may do the trick. I'll try incorporating that into what I'm using but I'm a bit of a neophyte on javascripting...

In your referenced javascript, I would imagine for my purposes, the X2 would be the name of the form file field - yes? and, what is the X4 argument?

Note that I did try adding all the various wordperfect designations and none of them worked a'tall.
0
The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

 

Author Comment

by:jlynn_tn
ID: 12321437
hiranmaya - was this a response to *this* question? I don't understand...
My intent is to filter out all files other than text, word processor, and pdf files.
My original query was with regards to cffile 'accept' - which won't accept WordPerfect files. I don't see how your solution will fix this - am I missing something?
Thanks tho, for taking time to reply!
jLynn
0
 
LVL 7

Expert Comment

by:black0ps
ID: 12321564
x1 is the name of the form // for reference to the field
x2 is the name of the upload field
x3 is the list of extensions you want to accept.
  It needs to be called with an onSubmit call like this:

<cfset formats = "correctFormats('Place','image','.txt,.rtf,.doc,.wpd,.wp,.wp5,.wp6,.pdf'); return submitform;">

<cfform name="Photo" action="index.cfm" enctype="multipart/form-data" onsubmit="#formats#">

When I was writing this code originally, x4 was going to be the extension in the file field. You can remove it, as it is no longer valid. The reason why I decided to go with client-side is because I could never get the mime type thing to work properly. I found by using client-side, that while a very small population do not have JS enabled, most people have it and it works well. It also means that the file doesn't get uploaded, then validated. It validates before it uploads.
0
 
LVL 7

Expert Comment

by:black0ps
ID: 12321573
So in cfset for formats, change out "Place" with the name of your form and change out "image" with the name of your field. They are case sensitive as well.

-- Ian
0
 

Author Comment

by:jlynn_tn
ID: 12324181
blackOps
All good, sound reasons for doing the client-side validation!
One question before I begin implementation... I currently use the 'onsubmit' for javascript validation of required fields - would I then move this validation into the 'correctFormats' function?
Again, thanks for this... will be helpful not only for this form but for the future as well!
jLynn
0
 
LVL 7

Expert Comment

by:black0ps
ID: 12324504
You can do it in two ways:
1. Adding the correctFormat() function to the end of your client-side form validation function

or

2. Use ColdFusion's built-in form validation using <cfform> and <cfinput>. I find those tags very powerful and time savers. ColdFusion will take whatever onsubmit function is in the cfform tag and insert into the built-in Javascript functions used for form validation.

Option 2 is my recommendation, but may mean a bit more work.
0

Featured Post

Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question