Skip to main content
Inspiring
August 12, 2021
Answered

Cffile or Cfinput file

  • August 12, 2021
  • 2 replies
  • 523 views

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 has been closed for replies.
    Correct answer ZNB

    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.

    2 replies

    BKBK
    Community Expert
    Community Expert
    August 12, 2021
    BKBK
    Community Expert
    Community Expert
    August 13, 2021

    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>

     

     

     

     

    ZNBAuthorCorrect answer
    Inspiring
    August 19, 2021

    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.

    EddieLotter
    Inspiring
    August 12, 2021

    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.