I have multiple dropzones in my ColdFusion code as such:
<cfform name='UploadFiles' action="uploadfiles.cfm" class="dropzone">
<input type="hidden" name="doctype" value="<cfoutput>#REQUIREMENT_CODE_KEY#</cfoutput>">
</cfform>
Currently when a file is uploaded, I put the original filename into my database and also rename the file and put that into the database. When the document is renamed, it uses the hidden value passed from the form (doctype).
Lets say someone uploaded the same file twice. This would put in the database two different renamed filenames (filename in image below), but it would have the same original filenames (orig_filename in image below). The only difference between the two records would be the value of the hidden element sent with the upload (doctype). ie:
The issue is that if they were to try to remove one of the files, both would be removed, because the only information dropzone has is the original filename. How can I get ColdFusion to pass the new filename back to the dropzone.js so that it can use that value to know exactly which line to delete?
Related
I am facing a little problem
I am writing .html file from dynamic pages like
<cffile action="write" file="#filename#" output="#trim(content)#" />
but problem is that if file already exists, the file will not be overwritten but the last modified date and time are updated some how.
I have also tried to delete the file first if file already exists, but .html show still the old contents. But if I manually delete the file then the newly generated file has actual contents.
I have a spreadsheet uploaded via Mura's file manager. I need to read that file using ColdFusion and for that I need a query object returned via the read() method of Mura's file manager bean. In order to call the read() method I will need the fileID. The problem is I don't have that. I have the filename and it will always be the same. I can't use $.content because the file wasn't uploaded to the current page. Any ideas?
Basically any ideas about how can I use this
<cfset file = #$.getBean('filemanager').readMeta(item.getFileID()).filename#>
That code does not work for me because it refers to item.getFileID and as I am not in a loop I am unable to use it.
Since you know the Mura content node that holds the file will always have the same name, you can load the content bean based on that name.
bean = $.getBean("content").loadBy(name={name}, siteID={siteID})
(siteid is optional)
If there are more content nodes with the same name, the call loadby function will return an array off all beans.
More info on loading content beans:
http://docs.getmura.com/v6/back-end/base-mura-objects-beans/loading-beans/
Once you've got the right content bean, you can ask for it's fileId.
bean.getFileId()
I am using <cfpdfform> to populate a LiveCycle Designer developed pdf form. I've excluded the destination attribute and the pdf shows in the browser exactly as I wish. However, it provides a filename of a series of numbers followed by=temp.pdf.
Is there any way to provide a variable name for the displayed file?
For example, if I provide a #URL.name# in my form submission, I would like the filename displayed in the browser to be smith.pdf or whatever name I place in the #URL.name#
I think this is what you need below. I once had to create a pdf document using cfdocument and I used the below to specify the filename to render as. The caveat is that i had to save the file on the file system first which i achieved with same cfdocument.
note path_to_pdf_file_on_server and name_to_render_as.pdf in the code below
<cfheader name="Content-Disposition" value="attachment;filename=name_to_render_as.pdf">
<cfcontent type="application/pdf" file="path_to_pdf_file_on_server" deletefile="Yes">
I am having a problem with the cffileupload tag and then inserting the names of the files uploaded into the database. It seems like there are no hooks back from the CF Action page that would say if it was successful, if the file was renamed, what the new filename is, and
Basically, I want a user to be able to upload mulitple files (up to 10) without a timeout and storing the name of the files in the database.
Any suggestions would be welcome! I've dug around on the interweb, and there doesn't seem to be any elegant solutions.
After the file is processed by <cffile action="upload">, there's a huge amount of information available via the variable specified in "result". This includes the original filename, the file size, and an indicator of success. Adobe's docs on cffile has the details. Your best bet is to create a temporary file, push the upload to there via cffile, evaluate success or failure, then push it into the database. Something like:
<cfset TemporaryFile = GetTempFile(GetTempDirectory(), "myAppTemp") />
<cffile action="upload" destination="#TemporaryFile#"
fileField="filefield" result="FileResults" />
Then you can access your file via the TemporaryFile variable, and the filename via FileResults.clientFile. FileResults.fileWasSaved should indicate success or failure of the upload and subsequent save to disk.
I have a JQUERY file upload plug-in which allows users to upload files to the Coldfusion server. The plugin submits the files to the server in a way that requires me to use GetHttpRequestData() for the files contents. Here's what I have so far in terms of handling the file data:
<cfparam name="URL.qqfile" type="string">
<cfset x = GetHttpRequestData()>
<cffile action="write" output="#x.content#" file="c:\temp\#URL.qqfile#">
This works, which is nice, but I can't seem to take this to the next step.
What I want to happen next is:
A. Determine the file's extension.
B. If it is an accepted ext defined by my app, (JPG,PNG,PDF, DOC, DOCX, etc...) upload it to the correct directory on the server. Then delete the temp file above
C. Use CFIMAGE to make a thumbnail if the file uploaded was an Image
How can I take the above through steps A-C with the GetHttpRequestData problem?
Thanks
A few tips:
Have a look at the result structure of GetHttpRequestData() via <cfdump>.
Pull out the necessary headers by accessing this struct. The Content-Type header usually contains the stuff you want to know. You can use the List functions (i.e. ListLen(), ListFirst(), ListLast(), ListRest() with appropriate delimiter chars) to easily parse the string.
Always use StructKeyExists() to safeguard against missing struct parts. Never take for granted anything that "typically" seems to be in this struct.
Don't blindly trust file extensions or the Content-Type header. Also look into the first few bytes of the uploaded file and compare them against a white list to confirm the file type.
Have a look at <cffile action="upload">.
Optionally, perfom a drive space test to assess if the uploaded data does not clog the server, or enforce limits in another way that suits you.
Read through the documentation of <cfimage>. It can't be that hard to use it to make thumbnails.