In m application, I have images files of various types that are being uploaded.
When the user uploads a file like AAAAA.jpg it downloads fine, but when the upload a file like AAAA, (1).jpg I get an error that says "You did not specify the name of a file to download.".
Is there a setting to allow this type of filename, or is there a way to change the filename in the upload script. The only challenge is I do not want to limit the type of file they can upload, therefore, harcoding the extension would not be an option.
Here is the upload function I am using
When the user uploads a file like AAAAA.jpg it downloads fine, but when the upload a file like AAAA, (1).jpg I get an error that says "You did not specify the name of a file to download.".
Is there a setting to allow this type of filename, or is there a way to change the filename in the upload script. The only challenge is I do not want to limit the type of file they can upload, therefore, harcoding the extension would not be an option.
Here is the upload function I am using
Code:
function savedFiles as v (e as p) 'This function is called after the file(s) selected in the Upload Files dialog have been uploaded to the server. 'The function is responsible for processing each uploaded file. 'The passed in 'e' object contains these properties dim count as n 'get a count of the number of files that were uploaded count = e.filecount dim i as n dim arr as p 'get the array that contains all of the uploaded files arr = e.filearray dim cn as sql::connection dim cs as c cs = e.tmpl.cs.connectionstring cn.open(cs) dim sql as c 'construct the sql statement to insert records into the child table sql = "insert into linkedAndEmbeddedFiles (ref_id, docdef, type) values (:claim_id, :filename, :doctype)" 'create a sql arguments object dim args as sql::arguments 'in order to related the new records we create in the 'linkedAndEmbeddedFiles' table the parent record 'we set the customerId in the this table to the primary key of the record in the parent grid. 'notice that the convert_type() function is called to convert the data to a numeric value (since the customerId field is a numeric field) args.add("claim_id",session.claim_id_sess) args.add("doctype",convert_type("3003","N")) Session.fileGuid = api_uuidcreate() 'now loop through all of the entries in the array, creating a new record in the child table for each file for i = 1 to count dim fn as c dim data as b 'get the binary data that was uploaded data = e.fileArray[i].data 'construct a filename. this is a server side filename. we want to store the files in the 'images' folder. fn = "C:\A5Webroot\gbsdev\images" + chr(92)+ Session.fileGuid + "-" + e.fileArray[i].fileName 'save the binary data to a file file.From_blob(fn,data) dim fntoStore as c fntoStore = "C:\A5Webroot\gbsdev\images" + chr(92) + Session.fileGuid + "-" + e.fileArray[i].fileName 'set the value of the 'filename' argument. args.add("filename",fntoStore) dim flag as l flag = cn.Execute(sql,args) if flag = .f. then e.javascript = "alert('Fatal error');" cn.close() exit function end if next i cn.close() 'send back a javascript command to the browser to cause the linked content to refresh. 'notice that the Grid method must be prefixed with 'window.parent' because this callback was fired from an IFrame. e.javascript = "window.parent.{grid.object}.refreshLinkedContent();" end function
Comment