Skip to main content
Inspiring
Aug 12, 2021 9:18 AM UTC
Answered

Cffile or Cfinput file

Bonjour,

Ma question est simple :

Quand, pour la première fois, je vais chercher un fichier : 

<CFINPUT type="file" action = "upload" name="Aut_photo" value="" size="50" accept="image/jpg, image/jpeg, image/gif"><br>

Pas de problème ! cela affiche, à côté du bouton "Parcourir", le nom du fichier !

Par contre, quand je veux consulter cette donnée à nouveau :

<CFINPUT type="file" action ="read" name="Aut_photo" value="/../../#session.site#/_Editeurs/#get_clients.Societe#/#MajAuteurs.Aut_Nom#/Auteur/#MajAuteurs.Aut_photo#">

Je n'ai plus aucune trace de ce dernier. J'ai le bouton "Parcourir" et la mention "Aucun fichier selectionné".

Merci d'avance pour votre aide.

 

Hello,

My question is simple:

When, for the first time, I go to look for a file:

<CFINPUT type = "file" action = "upload" name = "Aut_photo" value = "" size = "50" accept = "image / jpg, image / jpeg, image / gif"> <br>
No problem ! this displays, next to the "Browse" button, the name of the file!

On the other hand, when I want to consult this data again:

<CFINPUT type = "file" action = "read" name = "Aut_photo" value = "/../../# session.site # / _ Editors / # get_clients.Societe # / # MajAuteurs.Aut_Name # / Author / # ShiftAuthors.Aut_photo # ">
I no longer have any trace of the latter. I have the "Browse" button and the mention "No file selected".

Thank you in advance for your help.

 

    This topic is closed to new replies. Start a new post to keep the conversation going.
    ZNBCorrect answer
    Inspiring
    Aug 19, 2021 12:11 PM UTC

    Bonjour,

    C'est une excellente solution (pas facile !).

    Merci pour votre réponse.

     

    Hello,

    This is an excellent solution (not easy!).

    thank you for your reply.

    5 replies

    BKBK
    Community Expert
    Community Expert
    Aug 12, 2021 5:53 PM UTC
    BKBK
    Community Expert
    Community Expert
    Aug 13, 2021 4:21 PM UTC

    There is an alternative, which enables you to "programmatically" pass the value of the file path. You will need 2 CFM files:

     

     

     

    <!--- uploadFile.cfm --->
    
    <cfset filePath="C:\Users\BKBK\Desktop\dcba.pdf">
    
    <cfhttp url="http://localhost:8500/uploadIt.cfm" method="post" multipart="true">
        <cfhttpparam type="file" name="fileContent" file="#filePath#" >
    </cfhttp>
    

     

     

     

    <!--- uploadIt.cfm --->
    <cfif isDefined("form.fileContent") > 
    <!--- If TRUE, upload the file. --->
        <cffile action = "upload"
            fileField = "fileContent"
            destination = "c:\uploads\" 
            nameConflict = "overwrite" > 
    </cfif>

     

     

     

     

    Translate
    ZNBAuthorCorrect answer
    Inspiring
    Aug 19, 2021 12:11 PM UTC

    Bonjour,

    C'est une excellente solution (pas facile !).

    Merci pour votre réponse.

     

    Hello,

    This is an excellent solution (not easy!).

    thank you for your reply.

    Translate
    EddieLotter
    Inspiring
    Aug 12, 2021 2:18 PM UTC

    This is an HTML restriction.

    You cannot provide a value to the "input" element with a type of "file".

    The cfinput tag wraps the "input" HTML element.

    Translate