Cffile

I am using a cffile to delete a file from a directory on my server. On occasion I get an error stating that the file doesn't exist when in fact it does. I am using an absolute directory path: here is an example for my code.
    <cfif isDefined("Form.filename")>
    <cffile action="delete" file="C:\root\images\#Form.filename#">
    </cfif>
Prior to this running, I am uploading a file with a different name in the same directory.

I had something to the same issue you are having, and after pulling almost all my hair out over several weeks, I cam across this.
#71110 page 16 in http://www.adobe.com/support/documentation/en/coldfusion/801/cf801releasenotes.pdf
'Under heavy load, the cffile tag might attempt to create two temporary files with the same
name, resulting in problems such as missing file errors when trying to access a file.'
Althought I had different names, there is a hot fix out there that helped me.
The fix that helped me was:
http://blog.tygate.com/?p=403
I was working with flex and coldfusion 8 but this might help.

Similar Messages

  • How do I use CFTHREAD in combination with CFFILE Upload

    I've been reading how CFTHREAD is supposed to release the
    client so that long-lasting operations like a CFFILE upload can
    continue to do their business while the client does something else.
    How does this work exactly? I can't find any concrete
    references. For example, I have a regular file upload form. A user
    uploads a large file, say 100Mb, and I want to use CFTHREAD (or
    something) to handle the upload process, which I know may take
    hours depending on the connection, and immediately return the page
    for the client saying "Your file is being processed. Please check
    back later."
    I tried wrapping some CFFILE code with CFTHREAD, but when I
    ran it the page just sat there working while the file was being
    uploaded, so I did not witness any change whatsoever in how its
    being handled. What am I missing?
    <cfthread action="run" name="uploadVideo">
    <cffile
    action="upload"
    destination = "/var/www/video1/assetsIN"
    nameconflict="overwrite"
    filefield="video" />
    </cfthread>
    Thanks for any help.
    UPDATE: I asked Ben Forta this in an email yesterday and here
    was his response:
    What you are doing is correct. The actual file processing
    (getting the uploaded file) will not happen in a separate thread.
    Were you expecting a separate thread for the upload itself? CF
    can’t do that for you s CF does not have the file until it is
    uploaded. Actually, CF is not even called until the form is
    submitted (which includes the file being uploaded). It sounds like
    you want the browser to do an upload in the background. This may be
    doable using JavaScript and Ajax type controls. Or maybe using
    browser tabs or something. -Ben

    With file uploads the time consumption is between the client
    PC and the web
    server, not the web server and the CF server (which are
    usually on the same
    machine). All <cffile action="upload"> does is copy the
    uploaded file from
    the web server's temp upload dir to [wherever you tell it to
    go]: it's a
    local process, and should be fairly quick; certainly compared
    to the
    process of getting it to the web server in the first place.
    Even if the data transmission was between the client PC and
    the CF server,
    you can't expect <cfthread> to somehow increase the
    bandwitdh and speed up
    the file upload between the two machines.
    <cfthread> could come into its own if you had some file
    processing to
    perform on the file *after* it's uploaded: unzipping it,
    doing some image
    manipulation, parsing a CSV file into a DB, that sort of
    thing. Not for
    the initial upload.
    Adam

  • CFFILE Delete Error???

    I am trying to delete a file from a directory and am getting
    an error. The funny thing is that the file is actually deleting and
    then throwing the error. Has anybody experienced this? I am on a
    linux box running CFMX 7.
    ERROR:
    The destination
    "/xxxxxx/xxxxxx/xxxxxx/xxxxxx/xxxxxx/xxxxxx/xxxxxx/1881_1.tif"
    specified in the CFFILE tag is invalid.
    The destination either does not exist or is not accessible by
    this tag
    Why is it saying destination? I do not get it?
    Any help would be appreciated
    Thank You,
    Frank

    I believe the "Destination" piece is just they way they refer
    to the fiel you are deleting. I wouldnt dwell on it too much.
    As for the error, verify that the account used to run the
    ColdFusion service has access to that directory. It seems to be a
    permissions error.

  • Multiple cffile upload issues

    Hello all. I'm having a little issue with a multiple upload I
    am trying to achieve. I've been searching and searching but could
    not find an answer, and maybe you guys could help me. Well I'm
    doing multiple uploads on a form i created and it's uploading the
    file and file name correctly, but it's inserting 6 records
    everytime I'm hitting the submit button. Also, I've notice in my
    database is when you click the submit button, it's inserting the
    same file in one record 6 times, then it creates a new record and
    inserts the second file 6 times. I'm going to post the code here,
    maybe it's something I'm missing, not sure. Thanks for the help.

    dame.cranon wrote:
    > Hello all. I'm having a little issue with a multiple
    upload I am trying to
    > achieve. I've been searching and searching but could not
    find an answer, and
    > maybe you guys could help me. Well I'm doing multiple
    uploads on a form i
    > created and it's uploading the file and file name
    correctly, but it's inserting
    > 6 records everytime I'm hitting the submit button. Also,
    I've notice in my
    > database is when you click the submit button, it's
    inserting the same file in
    > one record 6 times, then it creates a new record and
    inserts the second file 6
    > times. I'm going to post the code here, maybe it's
    something I'm missing, not
    > sure. Thanks for the help.
    >
    >
    >
    > <cfloop index="i" from="1" to="6">
    >
    > <cfif isDefined("form.upload")>
    >
    > <cffile action="upload"
    > destination="D:\Hosting\streetzmag\dev\crush_images\"
    > filefield="pic#i#"
    > nameconflict="makeunique"
    > result="cffile.pic#i#"
    > accept="image/jpeg, image/pjpeg, image/gif" >
    >
    > <!--- Code for insert of information --->
    > <cfquery datasource="mysqlcf_streetzmag"
    name="uploaded">
    > INSERT INTO Information(firstname,
    > lastname,
    > email,
    > contact_info,
    > nickname,
    > recent_work,
    > hair_color,
    > eye_color,
    > ethnicity,
    > age,
    > height,
    > measurements,
    > pic_1,
    > pic_2,
    > pic_3,
    > pic_4,
    > pic_5,
    > pic_6
    >
    >
    > )
    > VALUES('#FORM.firstname#',
    > '#FORM.lastname#',
    > '#FORM.email#',
    > '#FORM.contact#',
    > '#FORM.nickname#',
    > '#FORM.work#',
    > '#FORM.hair#',
    > '#FORM.eye#',
    > '#FORM.ethnic#',
    > #FORM.age#,
    > '#FORM.height#',
    > '#FORM.measurements#',
    > <cfif isDefined("form.pic#i#") and
    evaluate("form.pic#i#") NEQ "">
    > <cfqueryparam
    value="#CFFILE['pic'&i].SERVERFILE#" cfsqltype="cf_sql_varchar"
    > />
    > <cfelse>
    > NULL
    > </cfif>,
    >
    > <cfif isDefined("form.pic#i#") and
    evaluate("form.pic#i#") NEQ "">
    > <cfqueryparam
    value="#CFFILE['pic'&i].SERVERFILE#" cfsqltype="cf_sql_varchar"
    > />
    > <cfelse>
    > NULL
    > </cfif>,
    >
    > <cfif isDefined("form.pic#i#") and
    evaluate("form.pic#i#") NEQ "">
    > <cfqueryparam
    value="#CFFILE['pic'&i].SERVERFILE#" cfsqltype="cf_sql_varchar"
    > />
    > <cfelse>
    > NULL
    > </cfif>,
    >
    > <cfif isDefined("form.pic#i#") and
    evaluate("form.pic#i#") NEQ "">
    > <cfqueryparam
    value="#CFFILE['pic'&i].SERVERFILE#" cfsqltype="cf_sql_varchar"
    > />
    > <cfelse>
    > NULL
    > </cfif>,
    >
    > <cfif isDefined("form.pic#i#") and
    evaluate("form.pic#i#") NEQ "">
    > <cfqueryparam
    value="#CFFILE['pic'&i].SERVERFILE#" cfsqltype="cf_sql_varchar"
    > />
    > <cfelse>
    > NULL
    > </cfif>,
    >
    > <cfif isDefined("form.pic#i#") and
    evaluate("form.pic#i#") NEQ "">
    > <cfqueryparam
    value="#CFFILE['pic'&i].SERVERFILE#" cfsqltype="cf_sql_varchar"
    > />
    > <cfelse>
    > NULL
    > </cfif>
    >
    > )
    > </cfquery>
    > </cfif>
    > </cfloop>
    >
    of course it will do everything 6 times since you have your
    whole code
    wrapped with cfloop from 1 to 6... so the code execution will
    happen 6
    times... plus your synatx for inserting filenames inside your
    query
    makes it insert same file 6 times (since the code is inside
    one same
    cfloop)...
    you should separate your code and wrap only the cffile part
    in a cfloop:
    <cfif isDefined("form.upload")>
    <cfloop index="i" from="1" to="6">
    <cfif len(trim(form.pic#i#)) gt 0>
    <cffile action="upload"
    destination="D:\Hosting\streetzmag\dev\crush_images\"
    filefield="pic#i#"
    nameconflict="makeunique"
    result="uploadedpic_#i#"
    accept="image/jpeg, image/pjpeg, image/gif" >
    </cfif>
    </cfloop>
    <!--- Code for insert of information --->
    <cfquery datasource="mysqlcf_streetzmag"
    name="uploaded">
    INSERT INTO Information
    (firstname,
    lastname,
    email,
    contact_info,
    nickname,
    recent_work,
    hair_color,
    eye_color,
    ethnicity,
    age,
    height,
    measurements,
    pic_1,
    pic_2,
    pic_3,
    pic_4,
    pic_5,
    pic_6)
    VALUES('#FORM.firstname#',
    '#FORM.lastname#',
    '#FORM.email#',
    '#FORM.contact#',
    '#FORM.nickname#',
    '#FORM.work#',
    '#FORM.hair#',
    '#FORM.eye#',
    '#FORM.ethnic#',
    #FORM.age#,
    '#FORM.height#',
    '#FORM.measurements#',
    <cfloop from="1" to="6" index="x">
    <cfif isdefined("uploadedpic_#x#")>
    <cfqueryparam value="#evaluate('uploadedpic_' & x)#"
    cfsqltype="cf_sql_varchar"/>
    <cfelse>
    NULL
    </cfif>
    <cfif x lt 6>,</cfif>
    </cfloop>)
    </cfquery>
    </cfif>
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Server side validation for file type with cffil sent via cfmail problem

    Hello;
    I have a small app that I need to allow users to be able to use a form, and send me and email with a file attachment. I have it working nicely, I included file manipulation into the validation process of the form and required form fields. The problem I'm having, is this. I'm trying to create and instance where if they try and upload lets say a pdf, it throws and error: "You are trying to upload the wrong file, please try again we only accept bla bla bla" Problem is, even if I'm uploading the proper file, it's rejecting it and deleting it. Can someone help me fix this? I've tried a number of different ways and can't seem to get this to go off properly. I am posting some of the code. There is a ton, so I'm posting the main parts so you get the idea and see my variables.
    <!--- Declairing my variables and setting up form validation--->
    <cfparam name="FORM.descript" type="string" default=""/>
    <cfparam name="FORM.attachment_1" type="string" default=""/>
    <cfset arrErrors = ArrayNew( 1 ) />
    <cfset showForm = true>
    <cfif structKeyExists(form, "sendcomments")>
    <cfif NOT len(trim(FORM.name))>
    <cfset ArrayAppend(arrErrors,"Your Full Name!<br>") />
    </cfif>
    <!--- This is where the file error control is as you can see how the name is validated, the file will be dealt with in a similar maner--->
    <cfif NOT Len(Trim(FORM.attachment_1))>
    <cfset ArrayAppend(arrErrors,"You didn't attach a file!<br>") />
    <cfelseif ArrayLen( arrErrors )>
    <cftry>
    <cffile action="DELETE" file="#FORM.resume#"/>
    <cfcatch>
    <!--- File delete error. --->
    </cfcatch>
    </cftry>
    <cfelse>
    <!--- no errors with the file upload so lets upload it--->
    <cftry>
    <cfset request.AcceptImage="image/gif,image/jpg,image/jpeg,image/pjpeg,image/x-png">
    <cffile action="upload"
                     filefield="attachment_1"
                     accept="#request.AcceptImage#"
                     destination="c:\websites\187914Kg3\uploads\"
                     nameconflict="Makeunique">
    <!---
    Now that we have the file uploaded, let's
    check the file extension. I find this to be
    better than checking the MIME type as that
    can be inaccurate (so can this, but at least
    it doesn't throw a ColdFusion error).
    --->
    <cfif NOT ListFindNoCase("request.AcceptImage",CFFILE.ServerFileExt)>
    <cfset ArrayAppend(arrErrors,"Only JPEG, GIF, and PNG file formats are accepted!<br>") />
    <!---
    Since this was not an acceptable file,
    let's delete the one that was uploaded.
    --->
    <cftry>
    <cffile action="DELETE" file="#CFFILE.ServerDirectory#\#CFFILE.ServerFile#"/>
    <cfcatch>
    <!--- File Delete Error. --->
    </cfcatch>
    </cftry>
    </cfif>
    <!--- This is the code that is causing my problem. The above code is saying everything is not the proper file and rejecting it all--->
    Can anyone help me out. I can make more of this code available if needed. Like i said, there's a lot and I didn't want to dump it all out, this is the section creating the problem. There are no errors at this time, just rejecting all file types.
    thank you.

    It appears you are comparing your content_length with 1MB.
    1KB: 1024 bytes
    1MB: 1024*1024 bytes
    Let us use max allowable size of 25KB here and amend the second half of our code.
    <!--- Set max allowable file size in KB at the top --->
    <cfset maxFileSize = 25>
          <!--- Check if file is an image file of acceptable size --->
          <cfif (#reFindNoCase("gif|jpg|jpeg|pjpeg|png",myResult.clientFileExt, 1)# EQ 1) AND (#myResult.FileSize# LTE (#maxFileSize#*1024))>
                <!--- Retain if right file type and size --->
                <p>
                Your file <strong>#myResult.clientFile#</strong> has been uploaded successfully!<br />
                <a href="yourTemplate.cfm">Back</a></p>
                <!--- Otherwise if wrong type --->
          <cfelseif #reFindNoCase("gif|jpg|jpeg|pjpeg|png",myResult.clientFileExt, 1)# NEQ 1>
                <p>
                You are trying to upload a <strong>#myResult.clientFileExt#</strong> file, please try again. We only accept <strong>gif, jpg, jpeg, and png</strong>.
                </p>
                <!--- Delete unacceptable file and show form to user to try again--->  
                <cffile action="delete"  file="#svrFile#" />
                      <form method="post" action=#cgi.script_name# 
                      name="uploadForm" enctype="multipart/form-data">
                      <input name="attachment_1" type="file">
                      <br>
                      <input name="submit" type="submit" value="Try again!">
                </form>
                <!--- Or size too large --->
          <cfelseif #myResult.FileSize# GT (#maxFileSize#*1024)>
                <p>
                Your file was too large (<strong>#numberFormat(myResult.fileSize/1024, "____.__")# KB</strong>). Please try a smaller file!
                </p>
                <!--- Delete file and show form--->
                <cffile action="delete"  file="#svrFile#" />
                      <form method="post" action=#cgi.script_name# 
                      name="uploadForm" enctype="multipart/form-data">
                      <input name="attachment_1" type="file">
                      <br>
                      <input name="submit" type="submit" value="Try again!">
                </form>
          </cfif>
    </cfif>        <!--- Closes the cfif tag which started from the first half --->
    </cfoutput><!--- ditto --->

  • Using cffile to make a unicode textfile

    Hi, I am trying to make a unicode text file from a query, I
    can make the file as a .csv file no problem using chr(34) as the
    field seperateor character, and all works fine, However I want to
    create a unicode .txt file that is identical to the same as the
    file created by excel when I save a .csv as a unicode .txt. After
    looking around in the cfforum I think I have learnt that I need to
    use charset=utf-8 attribute in cffiel, but I am not sure what I
    need to use as the seperator character (ie what does excel use?
    when it saves as a unicode txt file) many thanks
    Oli

    You can try the code in the following example.
    http://www.cflib.org/udf.cfm?id=1197&enable=1
    In order to save the file in Unicode you can use such as
    following syntax.
    <cffile action="write" charset="utf-8"
    file="#myPath#unicodeFile.txt" output="#myUnicodeContent#" />

  • Using a Forward Slash (/) in CFFILE Destination

    Hi everyone,
    I couldn't find this anywhere in the forums (at least not
    searching for "cffile forward slash", "cffile /", or "cffile
    destination") and hope I'm posting this in the correct place
    (please let me know if not). I need to use a forward slash (/) in
    the name of a file using cffile, but when I try to set destination
    = "c:\directory\file/name.txt" cf throws an exception and tells me
    that the system can't find the "c:\directory\file\" directory. Is
    there a way to froce ColdFusion to interpret the forward slash as
    part of the file name instead of a directory structure character?
    By the way I'm using ColdFusion 6.1 Standard Edition on a Windows
    box (obviously).

    quote:
    Originally posted by:
    Newsgroup User
    I could be wrong on that. I was not going on personal
    experience, just
    something that stuck in my mind when reading something. I
    cannot find the
    URL @ present, but I'm sure I read that the only actual
    *illegal* character
    in a *nix file name is the NULL character. But experience
    trumps reading.
    The best I could find is this:
    http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/iisbook/c03_converting _unix_file_names_and_pathnames.mspx?mfr=true.
    Although that is not where I originally read it.
    Adam
    The above sounds right and seems to be generally correct in
    practice (I'm testing by transferring files from OSX to Windows),
    with the exception of the "/" character. It's possible that "/"
    isn't, in fact, illegal to a *nix OS, but just isn't valid as a
    file name in any applications (including those that ship wtih the
    OS).
    However, It's also possible (read: probable) that I have no
    idea what I'm talking about. I'll see what I can find and post it
    here, would be good to know as I'm sure others have run into this
    (and I'm sure this won't be the last time I'm given a ridiculous
    naming convention).

  • Creating a directory before using cffile

    I'm having trouble using cffile right before I create a directory. I am using the cffileupload tag and my url attribute is a page that has the following code. Basically the code below creates a new directory and uploads all the images to that directory. However, it fails on the 2nd upload and i get a 500 error in the cffileupload flash object. However, if I hardcode the directory path, they all upload fine. Anyone know why I am having this problem?
    <!--- User will upload all the images to a temp directory based on date and time --->
    <cfset uploadFolderPath = "C:\ColdFusion9\wwwroot\MyApplication\uploads\" />
    <cfset date=DateFormat(Now(),'mm-dd-yyyy_') />
    <cfset time=TimeFormat(Now(),'hh-mm-ss') />
    <cfset newFolderName = "upload_" & date & time />
    <cfset newFolder = uploadFolderPath & newFolderName />
    <cfdirectory action = "create" directory="#newFolder#" />
    <cffile action="uploadall" destination="#newFolder#" nameconflict="makeunique" />

    It seems unlikely to be your problem, but be aware that <cffileupload> calls that URL once for each file uploaded, not just once.  That means the <cfdirectory> could conceivably be called twice within the same second, meaning the second call to it might fail because the dir already exists.
    You should probably check the dir exists before just assuming you're OK to create it.
    Adam

  • How to set destination for cffile

    Dear all ,
    I have a problem with <cffile> :
    my CFM file is in  : http://www.demo.com/panel/upload.cfm
    i want to store the file in  http://demo.com/gallery/news  folder
    so :
    <cfset file_name="demo.jpg">
    <cffile nameconflict="overwrite" action = "upload"  fileField = "n_file" destination = "../gallery/news/#file_name#">
    but i get error and i can not save it. i ask my friend and he told me should use full destination path lik "c:\website\demo.com\www\gallery\new" . is it currect ? and if yes , how can i get the server web folder path , because its not fix in all the server and may  be different in any server , also i use the MacOX and file system is not same as windows .

    You are almost there. The destination should be an absolute path to the directory in which the uploaded file will be stored.
    <cffile nameconflict="overwrite" action = "upload"  fileField = "n_file" destination = "#expandPath('..\gallery\news')#">

  • Simple file loader with cffile

    Hello;
    I'm trying to make a basic file loader for my web site. I've written the file upload, and it works. I'll attach that code. I was wondering if someone could help me over this small hurdle I need to get past... let me explain.
    I have an admin section in my web site. This file loader is to add new thumbnail images to a db record and show it on the front end. There is an option to either edit and existing record, or add a new record.
    When you get to the editor, I'm putting in a link for a pop up window that has this file loader in it. What I want to do it after you load this file, I need it to be able to close the window and add it to the editor section so the file name can be loaded into the database.
    Is this possible and kind of simple? I realize nothing is too simple doing this kind of programming, I'm just trying to find a decent solution that works. Maybe there is a tutorial out there for this kind of thing? Or maybe someone can help me with a couple lines of code so I can take it from there?
    This is my file loader:
    <cfset UploadFolder="c:\Inetpub\wwwroot\website\img\babies">
    <cfif IsDefined("Form.UploadFile") AND Form.UploadFile NEQ "">
    <cffile
         action="upload"
            filefield="UploadFile"
            destination="#UploadFolder#"
            nameconflict="overwrite"
            >
    File uploaded successfully!
        <br />
        Uploaded file: <cfoutput>#cffile.ClientFile#</cfoutput>
    <cfelse>
    Select a file first!       
    </cfif>
    <form name="UploadForm" method="post" enctype="multipart/form-data" action="">
    <input type="file" name="UploadFile">
        <input type="submit"  name="submit" value="Upload"/>
    </form>
    I can also post the db code for the page I'm loading it into if need be. I would have to refresh the page I believe to get the info from the pop up to the parent window that spawned it. I have a script for that:
    <a href="javascript:opener.top.location=('/test/edit-record.cfm');" onclick= "javascript:window.close();">close window</a>
    can anyone help me make this work properly? OR point me in a direction of a tutorial for a simple file loader of this type?
    thank you.

    I was wondering if Ajax would be a good solution. Can you tell me this
    ? I have a file loader I use all the time, but on this server, it's not working properly. Can you look at my code and possibly tell me why? I
    know this is a lot of code I'm pasting, but it is pretty strait forward. It doesn't thrown an error, it just doesn't load the file
    at all.
    I would rather use this, I have it all written:
    <!--- form submitted --->
    <!--- set file uploading vars --->
    <cfparam name="fileuploaded" type="boolean" default="false">
    <cfparam name="uploadedfile" default="">
    <cfset pathToFile = "c:\Inetpub\wwwroot\website\img\babies">
    <!--- --->
    <cfif len(trim(form.MYFile))>
    <!--- if a file has been selected --->
    <!--- try uploading new file --->
    <cftry>
    <cffile Action="upload" filefield="MYFile" accept="image/gif,
    image/jpg, image/jpeg, image/pjpeg"
    destination="#pathToFile#" nameconflict="MAKEUNIQUE">
    <cfset fileuploaded = true>
    <cfset uploadedfile = cffile.serverfile>
    <cfcatch type="any">
    <!--- if upload did not suceed, reset file uploading vars --->
    <cfset fileuploaded = false>
    <cfset uploadedfile = "">
    <!--- this can be further enhanced by setting some var to hold error
    message and return it to user --->
    </cfcatch>
    </cftry>
    </cfif>
    <cfif form.id gt 0><!--- we are updating an existing record --->
    <!--- if new file upload was successful and the feature has an image
    associated with it - delete old image --->
    <cfif fileuploaded is true AND len(trim(form.oldimage))>
    <cfif FileExists(pathToFile & form.oldimage)>
    <cffile action="delete" file="#pathToFile & form.oldimage#">
    </cfif>
    </cfif>
    <cfquery datasource="#APPLICATION.dataSource#">
    UPDATE baby_port
    SET
    baby_port.dob=<cfqueryparam cfsqltype="CF_SQL_DATE" value="#form.edit1#">,
    baby_port.Fname=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.Name#">,
    baby_port.Lname=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.Lname#">,
    <cfif fileuploaded is true>
    baby_port.MYFile=<cfqueryparam cfsqltype="cf_sql_varchar" value="#uploadedfile#">,
    </cfif>
    baby_port.Body=<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#form.PDSeditor#">,
    baby_port.weight=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.weight#">,
    baby_port.TimeB=<cfqueryparam cfsqltype="CF_SQL_TIME" value="#form.tob#">
    WHERE ID = <cfqueryparam value="#form.ID#" cfsqlType="CF_SQL_INTEGER">
    </cfquery>
    <cfelse><!--- we are inserting a new record --->
    <cfquery datasource="#APPLICATION.dataSource#">
    INSERT INTO baby_port
    (dob, Fname, Lname, MYFile, Body, weight, TimeB)
    VALUES
    (<cfqueryparam cfsqltype="CF_SQL_DATE" value="#form.edit1#">,
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.Name#">,
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.Lname#">,
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#uploadedfile#" null="#NOT fileuploaded#">,
    <cfqueryparam cfsqltype="cf_sql_longvarchar" value="#form.PDSeditor#">,
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.weight#">,
    <cfqueryparam cfsqltype="CF_SQL_TIME" value="#form.tob#">)
    </cfquery>
    </cfif>
    this is the 2 fields on the form that is submitting the file:
    <input type="hidden" name="oldimage" value="#MYFile#">
    <input name="MYFile" type="file" id="MYFile">
    I can make more available if you need it, I didn't want to unload a ton of code on you.This is a stand alone server running coldfusion 8.1 standard if that makes a difference, it is not a shared environment. I have this code working on shared environments.

  • Get the renamed filename after cffile rename

    i upload a file, rename that file, how do i get the new
    renamed file? thanks.

    Use the variable cffile.serverfile
    Also, do a <cfdump var="#cffile#"> and you'll see all
    the variables available to you.

  • Uploading documents using CFFile

    I am using CFFile for uploading documents using Cold Fusion 8
    in my Intranet environment. Each record has a limit of 20 documents
    that can be uploaded into MySQL database. It seems if I upload
    mulitple documents at around 1mb it takes less than a minute to
    complete. The problem seems to be when I upload muliptle documents
    that are bigger.
    If I attempt to upload 2 documents each over 25mb it takes
    around 10 minutes.
    Anyone have suggestions on alternatitve way to do this or
    should I just limit size of each upload to 4mb and less?

    Isn't this just a product of your internet speed and the size
    of the upload?

  • Intermittent error with CFFILE copy

    I have a problem that's driving me nuts and I don't see it in
    here already (I apologize if it is and I just missed it).
    We have ColdFusion 5.0 (yes, I know it's old) and I've been
    using it for an in-house billing program. One of the things it does
    is use CFFILE to copy a PDF version of the bill to the boss's
    machine. This what that part of the code looks like:
    <cffile action="COPY"
    source="\\testweb\wwwroot\Billing\invoices\#attachment#"
    destination="\\Obi-wan\Data\Glenns Code Backup\QB
    invoices\#attachment#">
    This is an example of what I get:
    Error processing CFFILE
    Unable to copy file
    '\\testweb\wwwroot\Billing\invoices\Emmi_Solutions,_LLC-Mulert-Asthma_Action_Plans-Round_ 1-No_7661.pdf'
    to path '\\Obi-wan\Data\Glenns Code Backup\QB
    invoices\Emmi_Solutions,_LLC-Mulert-Asthma_Action_Plans-Round_1-No_7661.pdf'.
    Error: The system cannot find the file specified. (error 2).
    The file has been created. It's THERE. I can open it. And
    sometimes this works without an error! Up until today, when we got
    this error, I'd reboot the CF server (testweb) and then it would
    work. Today, I've rebooted the server several times and it just
    won't.
    Any ideas?

    Below is the Snippet of code.
    It never makes it past this first line. It almost seems like
    something on IIS5. I creates the file,but stops at 1048 kb. But
    this is weird, when the error message appears, the file becomes
    7.8m. The entire file is 8megs
    <CFFILE ACTION="Upload"
    FILEFIELD=#Attributes.SourceField#
    DESTINATION="#TargetFile#.tmp"
    NAMECONFLICT="MAKEUNIQUE" ATTRIBUTES="Temporary">
    <CFSET FileName = CFFile.ClientFile>
    <CFSET FileSize = CFFile.FileSize>
    <!--- DETERMINE MIME TYPE --->
    <CF_MIME EXTENSION=#File.ClientFileExt#
    TYPE=#File.ContentType# SUBTYPE=#File.ContentSubType#>
    <!--- MOVE IT TO CORRECT LOCATION (REPLACING OLD VERSION,
    IF NECESSARY) --->
    <CFFILE ACTION="Rename" SOURCE="#TargetFile#.tmp"
    DESTINATION="#TargetFile#" ATTRIBUTES="Normal">

  • Looping over CFFILE only writes last line

    Here is the code in question:
    <CFSET LINECOUNT = 0>
    <cfloop list="#populate#" index="CL">
          <CFOUTPUT>#CL#:<input type="text" name="#CL#"><BR></CFOUTPUT>
          <CFSET LINECOUNT = LINECOUNT + 1>
          <CFSET ThisNewLine = '<input type="text" name="#CL#">#CL#'>
          <cffile action="append" file="#Application.BaseRef#Temp\#URL.Field#.CFM" output="#ThisNewLine#" addnewline="Yes">
    </cfloop>
    Linecount = <CFOUTPUT>#LineCount#</CFOUTPUT>
    The list populate# has 28 items in it, the output to the screen is 28 lines of input boxes, the line count variable value is 28 but only one line (The last line) is written to the file.
    What is the world am I overlooking?
    Thanks,
    Kev

    Well, I went to clean up my code to get rid of all the debug "stuff" I put in there trying to determine the root cause so I could post the whole shebang for you and after I removed all the "stuff" I executed it again to make sure that I didn't introduce a new error and whatever was causing the problem is now no longer there.  I apologize to the community for wasting the bandwidth.
    If ignorance is bliss, why am I not happy?

  • CFFILE Holding File Locks

    I have a CF page that reads some tab-delimited text files for
    processing. After it reads a file it then calls a CF page to move
    the file to a new location. It moves the file, but it does not
    delete the old version -- and a filesystem delete on the file fails
    -- it appears as if the CF server has the file locked. If I shut
    down the server and restart it, it clears the lock.
    <cfif #url.vendor# is "LOWES">
    <cflock timeout="10" scope="server" throwOnTimeout="no"
    type="exclusive">
    <cffile action="move"
    source="c:\edifiles\export\#url.fileno#"
    destination="c:\edifiles\export\done\lowes\#url.fileno#">
    </cflock>
    </cfif>

    Generally when manipulating files you used a named
    <cflock> instead of a scope like so:
    <cflock name="#Variables.myFileName#" timeout="5"
    type="exclusive">
    In your code in the second example I'm not sure about the
    function of the loop at all... I guess you are trying to delay to
    make sure the copy operation completes before deleting. But looping
    from 1 to 10 is arbitrary and depending on other concurrent
    processes, server speed, RAM, etc. and so basically it is
    unreliable.

Maybe you are looking for