1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
if XMLApplication.InitParams.Values['XMLC_AllowFileUpload'] <> '1' then
XMLRequest.RaiseError('ERR_FILE_UPLOAD_NOT_ALLOWED', ClassName+'.XMLC_UploadFile');
if context.Values['file'] = '' then
begin
if XMLC_TraceInfo then EventLog.TraceInfo(XMLRequest, ClassName, 'XMLC_UploadFile - Pas de fichier à télécharger');
Exit;
end;
UploadDir := XMLApplication.InitParams.Values['XMLC_FileUploadDir'];
if UploadDir = '' then
UploadDir := 'Upload';
UploadDir := ConcatDir(XMLApplication.InitParams.Values['XMLC_DefaultDataDir'], UploadDir, True);
filename := context.Values['CA_ID']+ '_' + ExtractFileName( context.Values['file']);
context.Values['CA_FILENAME']:= filename;
FileName := ConcatDir(UploadDir, FileName, False);
if FileExists(FileName) then
XMLRequest.RaiseError('ERR_UPLOADED_FILE_ALREADY_EXISTS', ClassName+'.XMLC_UploadFile - FileName[''+FileName+'']');
if XMLC_TraceInfo then EventLog.TraceInfo(XMLRequest, ClassName, 'XMLC_UploadFile - ' + context.Values['file'] + ' dest : ' + filename);
WriteStringToFile(context.Values['file'], FileName, False); |