Oh this is wierdness!
here's the idea
try
upload a file
--------------------
try
database insert sproc
get @@identity PK sproc
catch
database errors
delete uploaded file
end catch
catch
any errors for the db try
delete uploaded file
end catch
end try
--------------------
catch
file errors
end catch
catch
any errors for the file try
end catch
end try
if the path is totally wrong (eg wrong drive) then the file's <cfcatch>
kicks in fine
BUT if the path is only partly wrong (C:\CFusionMX\wwwroot\gallery\imagesXX\
instead of C:\CFusionMX\wwwroot\gallery\images\) then the file name gets
changed from *sample.jpg* to *imagesXX* (which is recorded in the db) and
it gets saved in C:\CFusionMX\wwwroot\gallery
so,
1) how come the upload still works (incorrectly) when the path is not
entirely correct?
2) can <cftry> be nested so errors in the inner try bubble up to the outer
try correctly?
3) is there a performance hit using nested try/catch Vs defensive
programming (<cfif>)
as found in other languages?
any ideas?
thanx
barry.b
here are some testing results. none of them should have worked AT ALL
and the file's <cfcatch> type="file" or type="any" should have
kicked in (path not found error)
the test file is called DCP_5908.JPG (relying on MAKEUNIQUE)
the actual file path is c:\CFusionMX\wwwroot\gallery\images\
the incorrect (code) file path is c:\CFusionMX\wwwroot\gallery\imagesXX\
******************** one *************************************
Variables.imagePath=c:\CFusionMX\wwwroot\gallery\imagesXX\
XXXXXXXXX upload done XXXXXXXXXXXXX
XXXXXXX proc done XXXXXXX
XXXXXXXX debug values XXXXXXXX
file.serverFile = imagesXX
qImage.idImage = 17
full file path = c:\CFusionMX\wwwroot\gallery\imagesXX\imagesXX
(a file called imagesXX is written in C:\CFusionMX\wwwroot\gallery
and an entry for the file imagesXX is inserted into the db)
********************* two **************************************
Variables.imagePath=c:\CFusionMX\wwwroot\gallery\imagesXX\
XXXXXXXXX upload done XXXXXXXXXXXXX
XXXXXXX proc done XXXXXXX
XXXXXXXX debug values XXXXXXXX
file.serverFile = DCP_5908.JPG
qImage.idImage = 18
full file path = c:\CFusionMX\wwwroot\gallery\imagesXX\DCP_5908.JPG
(a file called DCP_5908.JPG is written in C:\CFusionMX\wwwroot\gallery
and an entry for the file DCP_5908.JPG is inserted into the db)
*********************** three *******************************
Variables.imagePath=c:\CFusionMX\wwwroot\gallery\imagesXX\
XXXXXXXXX upload done XXXXXXXXXXXXX
XXXXXXX proc done XXXXXXX
XXXXXXXX debug values XXXXXXXX
file.serverFile = DCP_59081.JPG
qImage.idImage = 19
full file path = c:\CFusionMX\wwwroot\gallery\imagesXX\DCP_59081.JPG
(a file called DCP_59081.JPG is written in C:\CFusionMX\wwwroot\gallery
and an entry for the file DCP_59081.JPG is inserted into the db)
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MX Downunder AsiaPac DevCon - http://mxdu.com/