Link to home
Start Free TrialLog in
Avatar of sharon212
sharon212

asked on

CFFILE upload and read!

Hi,

I need users to upload a file from the desktop and want them to store it in this folder "c:\CFprojects\Docs\". After that, if there is a document in this folder, I need that to be linked in the page.

Please help me out.

Thanks in advance.
Avatar of SidFishes
SidFishes
Flag of Canada image



<cfset varTmp = form.doc>


<cffile action="UPLOAD"
        filefield="form.doc"
        destination="c:\CFprojects\Docs\"
        nameconflict="MAKEUNIQUE"
        accept="*.*">

Upload Results
<cfoutput>
<cfif fileexists("c:\CFprojects\Docs\#form.doc#")>
#form.doc#
</cfif>
</cfoutput>

or on a page other than the upload page

<cfdirectory action="list" directory="c:\CFprojects\Docs\" name="myDir">

<cfoutput query = "MyDir">
<a href="http://relativepathto/cfprojects/docs/#myDir.name#">#myDir.name#</a>
</cfouput>





Avatar of sharon212
sharon212

ASKER

Hey thanks.

I could upload my files.

But I am not able to link that file in my web page.

Hi, I could get the links too.. but it is not opening.  When I click the link, it says "the page cannot be found"
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

    <tr>
      <td class = "tdhdr-v"> Upload </td>
      <td class = "tdhdr1"> <input type = "file" name = "Nprtfile" size = "20" >
                        <input type="submit" name="fileUpload" value="Go!" />
      </td>
    </tr>

<cffile action = "upload"  
      fileField = "Nprtfile"  
      destination = "c:\CFProjects\DevAG\temp\"
      accept = "image/jpg, application/ms-excel, application/msword, application/pdf">

<cfdirectory action="list" directory="c:\CFprojects\DevAG\Temp\" name="Dirfil">

</cfoutput>

<cfoutput query = "Dirfil">
<tr>
<a href="http://mypath/cfprojects/DevAG/#Dirfil.name#">#Dirfil.name#</a>
</tr>
</cfoutput>

And also I am not able to upload ms-excel files.


try adding

<cfoutput query = "Dirfil">
<tr>
<a href="http://mypath/cfprojects/DevAG/#Dirfil.name#.DOC">#Dirfil.name#</a>
</tr>
</cfoutput>

 If that works we'll be needing some extension handling...
Thank you very much for your help. What I did was, just I made it mypath under the webserver (inet). that's all. It works great.