Copy link to clipboard
Copied
Bonjour,
Alors que je l'ai fait de nombreuses fois dans d'autres programmes, cette fois-ci j'ai une erreur :
<cfset DIR=#db_dir# & "#session.site#" & "/" & "_Ouvrages" & "/" & "APED" & "/" & "Auteurs" & "/" & "MOSTARAN">
<cfset DIRB=#DIR# & "/" & "hello">
<CFIF not DirectoryExists(#DIRB#)>
<CFDIRECTORY action="CREATE" directory="#verifdirb#">
</CFIF>
Voici le message d'erreur :
An error occurred when performing a file operation create on file http://localhost:8500/SoLivres/_Ouvrages/APED/Auteurs/MOSTARAN/hello.
The cause of this exception was: org.apache.commons.vfs2.FileSystemException: Invalid absolute URI "http://localhost:8500/SoLivres/_Ouvrages/APED/Auteurs/MOSTARAN/hello"..
Merci d'avance pour votre aide !
Cordialement
Mais je ne comprends pas pourquoi il faut inialiser une nouvelle variable !
<cfset testDir=DIR & "\" & "myTestDirectory">
alors que juste au dessus on a une variable identique :
<cfset DIRB=#DIR# & "/" & "hello">
Mystère !
Merci pour votre éclairage.
By @ZNB
Bonjour @ZNB ,
The only difference is that your code creates the directory "hello", whereas mine creates the directory "myTestDirectory". Apart from that, your line of code is essentially identical to mine.
The FileSystemException o
...Copy link to clipboard
Copied
You have mixed two protocols: file and http. You should not use http://localhost with cfdirectory if you want to create a directory on the file-system. You should instead use the file's absolute path.
The file path that corresponds to http://localhost:8500 is wwwroot. Its absolute path is expandPath("").
Hence, the http path
http://localhost:8500/SoLivres/_Ouvrages/APED/Auteurs/MOSTARAN
corresponds to the file path
expandPath("") & "\" & "soLivres" & "\" & "_Ouvrages" & "\" & "APED" & "\" & "Auteurs" & "\" & "MOSTARAN"
Code example for you to test:
<!--- Absolute path--->
<cfset DIR=expandPath("") & "\" & "soLivres" & "\" & "_Ouvrages" & "\" & "APED" & "\" & "Auteurs" & "\" & "MOSTARAN">
<cfset testDir=DIR & "\" & "myTestDirectory">
<!--- If the test directory does not exist, create it --->
<CFIF not DirectoryExists(testDir)>
<CFDIRECTORY action="CREATE" directory="#testDir#">
</CFIF>
Copy link to clipboard
Copied
Bonjour,
En effet cela marche !
Mais je ne comprends pas pourquoi il faut inialiser une nouvelle variable !
<cfset testDir=DIR & "\" & "myTestDirectory">
alors que juste au dessus on a une variable identique :
<cfset DIRB=#DIR# & "/" & "hello">
Mystère !
Merci pour votre éclairage.
Copy link to clipboard
Copied
Mais je ne comprends pas pourquoi il faut inialiser une nouvelle variable !
<cfset testDir=DIR & "\" & "myTestDirectory">
alors que juste au dessus on a une variable identique :
<cfset DIRB=#DIR# & "/" & "hello">
Mystère !
Merci pour votre éclairage.
By @ZNB
Bonjour @ZNB ,
The only difference is that your code creates the directory "hello", whereas mine creates the directory "myTestDirectory". Apart from that, your line of code is essentially identical to mine.
The FileSystemException occurs because the value of the directory attribute in cfdirectory contains db_dir & session.site as part of the directory's absolute path. However, the string db_dir & session.site contains http://localhost:8500. This is an http path, not a file path.
You should, in place of http://localhost:8500, use the corresponding value for file path. It is expandPath(""). That is what the test demonstrates.