xmlhttprequest - Coldfusion, using GetHttpRequestData, to Store and Handle Files -


i have jquery file upload plug-in allows users upload files coldfusion server. plugin submits files server in way requires me use gethttprequestdata() files contents. here's have far in terms of handling file data:

<cfparam name="url.qqfile" type="string"> <cfset x = gethttprequestdata()> <cffile action="write" output="#x.content#" file="c:\temp\#url.qqfile#"> 

this works, nice, can't seem take next step.

what want happen next is: a. determine file's extension. b. if accepted ext defined app, (jpg,png,pdf, doc, docx, etc...) upload correct directory on server. delete temp file above c. use cfimage make thumbnail if file uploaded image

how can take above through steps a-c gethttprequestdata problem?

thanks

a few tips:

  • have @ result structure of gethttprequestdata() via <cfdump>.
  • pull out necessary headers accessing struct. content-type header contains stuff want know. can use list functions (i.e. listlen(), listfirst(), listlast(), listrest() appropriate delimiter chars) parse string.
  • always use structkeyexists() safeguard against missing struct parts. never take granted "typically" seems in struct.
  • don't blindly trust file extensions or content-type header. first few bytes of uploaded file , compare them against white list confirm file type.
  • have @ <cffile action="upload">.
  • optionally, perfom drive space test assess if uploaded data not clog server, or enforce limits in way suits you.
  • read through documentation of <cfimage>. can't that hard use make thumbnails.

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -