Re: Add to a filename in multifile upload

This WebDNA talk-list message is from

2002


It keeps the original formatting.
numero = 42310
interpreted = N
texte = on 8/5/02 9:38 PM, Lester Emo at lester@klinternet.com so noted...> I have people upload photos files for ad listings and I'm trying to > identify them after uploading.I *thought* that code looked familiar -- and the comment about Windows' path names clinched it. ; )That code was used in a situation where the files were being uploaded in a controlled environment and the filename could be used as submitted. If access is more open, you're going to want to check file type and set filename yourself.This is something that determines the file type based upon the submitted MIME type. The name is entered in another field on the upload form ([picText.n]) and has spaces removed, is trimmed for size, and a CYA random number added. In your case, you could use something like the name of the listing for the name, and just add an incremental number to the end.It supports a variety of file types, you could limit it to GIF and JPEG (or whatever you're using).At the end, [ca_picError] will equal T if any errors were encountered, [ca_picError.n] will be the error message for that pic (here, just for unsupported type) and [ca_pic.1] through [ca_pic.n] will be the name created for the uploaded files. [formvariables] [showif [url][name][/url]^%22theFile][if [url][value][/url]!][then] [text]ca_fileType=[middle startafter=Content-Type: ][name][/middle][/text][if ([ca_fileType]^/gif)][then][text]ca_fileExt=gif[/text][/then][else] [if ([ca_fileType]^/jpeg)][then][text]ca_fileExt=jpeg[/text][/then][else] [if ([ca_fileType]^/msword)][then][text]ca_fileExt=doc[/text][/then][else] [if ([ca_fileType]^/plain)|([ca_fileType]^/x-usenet-faq)][then][text]ca_ fileExt=txt[/text][/then][else] [if ([ca_fileType]^/rtf)|([ca_fileType]^/x-rtf)|([ca_fileType]^/richt ext)][then][text]ca_fileExt=rtf[/text][/then][else] [if ([ca_fileType]^/mspowerpoint)|([ca_fileType]^/powerpoint)|([ca_file Type]^/vnd.ms-powerpoint)|([ca_fileType]^/x-mspowerpoint)][then][text ]ca_fileExt=ppt[/text][/then][else] [if ([ca_fileType]^/pdf)][then][text]ca_fileExt=pdf[/text][/then][else] [if ([ca_fileType]^/x-compressed)|([ca_fileType]^/x-zip-compressed)|([c a_fileType]^/zip)|([ca_fileType]^/x-zip)][then][text]ca_fileExt=zip[/ text][/then][else] [if ([ca_fileType]^/x-sit)|([ca_fileType]^/x-stuffit)][then][text]ca_fil eExt=sit[/text][/then][else] [text multi=T]ca_picError=T&ca_localErr=T&ca_picError.[index]=Uploaded file is not a supported type[/text] [/else][/if][/else][/if][/else][/if][/else][/if][/else][/if][/else][/if][/el se][/if][/else][/if][/else][/if][showif [url][value][/url]!][showif [ca_localErr]!T][math show=f]ca_picTotal=1[/math][text]ca_pic.[index]=[getchars start=1&end=20][lowercase][grep search=[^a-zA-Z0-9]&replace=][text]picText.[index][/text][/grep][/lowercase] [/getchars][getchars start=1&end=4][random][random][random][random][/getchars].[ca_fileExt][/text ][writefile file=[text]ca_pic.[index][/text]&secure=F][value][/writefile][/showif][/showif][/then][/if] [/showif] [/formvariables] Rob Marquardt Designer/Resident Wirehead Toast Design800 Washington Avenue North Minneapolis MN 55401 612.330.9863 v 612.321.9424 f www.toastdesign.com ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Add to a filename in multifile upload (Rob Marquardt 2002)
  2. Re: Add to a filename in multifile upload (Lester Emo 2002)
  3. Re: Add to a filename in multifile upload (Stuart Tremain 2002)
  4. Re: Add to a filename in multifile upload (Kenneth Grome 2002)
  5. Add to a filename in multifile upload (Lester Emo 2002)
on 8/5/02 9:38 PM, Lester Emo at lester@klinternet.com so noted...> I have people upload photos files for ad listings and I'm trying to > identify them after uploading.I *thought* that code looked familiar -- and the comment about Windows' path names clinched it. ; )That code was used in a situation where the files were being uploaded in a controlled environment and the filename could be used as submitted. If access is more open, you're going to want to check file type and set filename yourself.This is something that determines the file type based upon the submitted MIME type. The name is entered in another field on the upload form ([picText.n]) and has spaces removed, is trimmed for size, and a CYA random number added. In your case, you could use something like the name of the listing for the name, and just add an incremental number to the end.It supports a variety of file types, you could limit it to GIF and JPEG (or whatever you're using).At the end, [ca_picError] will equal T if any errors were encountered, [ca_picError.n] will be the error message for that pic (here, just for unsupported type) and [ca_pic.1] through [ca_pic.n] will be the name created for the uploaded files. [formvariables] [showif [url][name][/url]^%22theFile][if [url][value][/url]!][then] [text]ca_fileType=[middle startafter=Content-Type: ][name][/middle][/text][if ([ca_fileType]^/gif)][then][text]ca_fileExt=gif[/text][/then][else] [if ([ca_fileType]^/jpeg)][then][text]ca_fileExt=jpeg[/text][/then][else] [if ([ca_fileType]^/msword)][then][text]ca_fileExt=doc[/text][/then][else] [if ([ca_fileType]^/plain)|([ca_fileType]^/x-usenet-faq)][then][text]ca_ fileExt=txt[/text][/then][else] [if ([ca_fileType]^/rtf)|([ca_fileType]^/x-rtf)|([ca_fileType]^/richt ext)][then][text]ca_fileExt=rtf[/text][/then][else] [if ([ca_fileType]^/mspowerpoint)|([ca_fileType]^/powerpoint)|([ca_file Type]^/vnd.ms-powerpoint)|([ca_fileType]^/x-mspowerpoint)][then][text ]ca_fileExt=ppt[/text][/then][else] [if ([ca_fileType]^/pdf)][then][text]ca_fileExt=pdf[/text][/then][else] [if ([ca_fileType]^/x-compressed)|([ca_fileType]^/x-zip-compressed)|([c a_fileType]^/zip)|([ca_fileType]^/x-zip)][then][text]ca_fileExt=zip[/ text][/then][else] [if ([ca_fileType]^/x-sit)|([ca_fileType]^/x-stuffit)][then][text]ca_fil eExt=sit[/text][/then][else] [text multi=T]ca_picError=T&ca_localErr=T&ca_picError.[index]=Uploaded file is not a supported type[/text] [/else][/if][/else][/if][/else][/if][/else][/if][/else][/if][/else][/if][/el se][/if][/else][/if][/else][/if][showif [url][value][/url]!][showif [ca_localErr]!T][math show=f]ca_picTotal=1[/math][text]ca_pic.[index]=[getchars start=1&end=20][lowercase][grep search=[^a-zA-Z0-9]&replace=][text]picText.[index][/text][/grep][/lowercase] [/getchars][getchars start=1&end=4][random][random][random][random][/getchars].[ca_fileExt][/text ][writefile file=[text]ca_pic.[index][/text]&secure=F][value][/writefile][/showif][/showif][/then][/if] [/showif] [/formvariables] Rob Marquardt Designer/Resident Wirehead Toast Design800 Washington Avenue North Minneapolis MN 55401 612.330.9863 v 612.321.9424 f www.toastdesign.com ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Rob Marquardt

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

[OT] (waaaay OT) (2004) WebCatalog 4.0 Users that want to talk to the Media.... (2000) [OT] Who's got a cool link (2002) WebCat2b15MacPlugin - [protect] (1997) WebCat2b15MacPlugin - [protect] (1997) Plugin or CGI or both (1997) OT: Urgent help with Windows and Javascript (2003) using WebCat for Associate Programs? (1998) OK, here goes... (1997) email preferences on NT (1997) flushdatabases (2000) Reindexing a db with duplicate numbers... (1999) Just a thought (1998) WebCat2: Formulas.db question (1997) Categories and Sub-categories (2003) Hiding HTML and page breaks (1997) Webcat & SIMS (1998) Separate SSL Server (1997) Suffix Mapping (1997) WebCat2 Append problem (B14Macacgi) (1997)