Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple file upload with MAC O/S

Status
Not open for further replies.

luciai

Programmer
Jul 25, 2002
13
CA
I have a problem with uploading multiple images on the MAC using IE 5 and 5.5 browsers. <CFFILE> works fine with IE and Netscape but not on OS MAC IE. I have 6 form fields for images, if uploading 6 images, it works. However if uploading less than 6, it does not work.

When using ENCTYPE=&quot;multipart/form-data&quot;, MAC IE appends characters to all form fields. And this can be resolved with using the Trim() and StripCR() functions. But it's not working for me. I also found out that when these files are uploaded to the server they are assigned temporary names as they are being uploaded. IE on the MAC catches this, and thinks it is a file name. When it tries to pass, it gives an error on the &quot;cffile&quot; line.

Does any one have sample uploading code that they would like to share that works for the OS MAC IE? Any help would be appreciated! Thank you.

My code is as follows:

<CFTRANSACTION>
<CFLOCK TIMEOUT=&quot;30&quot; NAME=&quot;addTales&quot; TYPE=&quot;EXCLUSIVE&quot;>
<CFQUERY NAME=&quot;InsertTales&quot; DATASOURCE=&quot;#datasource#&quot;>
INSERT INTO Tales(Title, Story, SubmitDate, Program, ProgramYear, Author, Email, Approval)
VALUES('#Trim(FORM.Title)#','#Trim(FORM.EditorValue)#', '#Trim(FORM.SubmitDate)#', '#Trim(FORM.Program)#', #Trim(FORM.ProgramYear)#,'#Trim(FORM.Author)#', '#Trim(FORM.Email)#', '#Trim(Form.Approval)#')
</CFQUERY>

<CFQUERY Name=&quot;GetLastTalesID&quot; DataSource=&quot;#datasource#&quot;>
SELECT MAX(TalesID) AS LastStoryID
FROM Tales
WHERE Title='#Trim(Form.title)#'
AND author='#Trim(Form.author)#'
</CFQUERY>




<!----check to see if the total file size being uploaded is too big----->
<CFIF VAL(CGI.CONTENT_LENGTH) GT #maxFileSize#>
Photos that you have uploaded are too large. This article has not been submitted.<br>
<CFABORT>
<CFELSE>


<!---1st image--->
<CFIF Trim(StripCR(Form.File1)) IS NOT &quot;&quot;>
<!---Call CF_AutoResize --->
<cf_autoresize imagepath=&quot;#varDestination#&quot; maxsize=&quot;#Trim(form.maxsize)#&quot; thumbsize=&quot;#Trim(form.thumbsize)#&quot; prefix=&quot;#Trim(form.prefix)#&quot; filefield=&quot;file1&quot; thumbpath=&quot;#Trim(thumbpath)#&quot;>
<!---Outputs the variables #photo# and #thumbnail#--->
<CFQUERY name=&quot;InsertImage1&quot; DATASOURCE=&quot;#datasource#&quot;>
UPDATE Tales
SET Image1='#photo#'
WHERE TalesID=#Val(GetLastTalesID.LastStoryID)#
</CFQUERY>

</CFIF><!----end of if file1 empty---->


<!---2nd Image--->

<CFIF Trim(StripCR(Form.File2)) IS NOT &quot;&quot;>
<!---Call CF_AutoResize --->
<cf_autoresize imagepath=&quot;#varDestination#&quot; maxsize=&quot;#Trim(form.maxsize)#&quot; thumbsize=&quot;#Trim(form.thumbsize)#&quot; prefix=&quot;#Trim(form.prefix)#&quot; filefield=&quot;file2&quot; thumbpath=&quot;#Trim(thumbpath)#&quot;>
<!---Outputs the variables #photo# and #thumbnail#--->
<CFQUERY name=&quot;InsertImage2&quot; DATASOURCE=&quot;#datasource#&quot;>
UPDATE Tales
SET Image2='#photo#'
WHERE TalesID=#Val(GetLastTalesID.LastStoryID)#
</CFQUERY>

</CFIF><!----end of if file2 empty---->

<!---3 Image--->
<CFIF Trim(StripCR(Form.File3)) IS NOT &quot;&quot;>
<!---Call CF_AutoResize --->
<cf_autoresize imagepath=&quot;#varDestination#&quot; maxsize=&quot;#Trim(form.maxsize)#&quot; thumbsize=&quot;#Trim(form.thumbsize)#&quot; prefix=&quot;#Trim(form.prefix)#&quot; filefield=&quot;file3&quot; thumbpath=&quot;#Trim(thumbpath)#&quot;>
<!---Outputs the variables #photo# and #thumbnail#--->
<CFQUERY name=&quot;InsertImage3&quot; DATASOURCE=&quot;#datasource#&quot;>
UPDATE Tales
SET Image3='#photo#'
WHERE TalesID=#Val(GetLastTalesID.LastStoryID)#
</CFQUERY>

</CFIF><!----end of if file3 empty---->

<!---4 Image--->
<CFIF Trim(StripCR(Form.File4)) IS NOT &quot;&quot;>
<!---Call CF_AutoResize --->
<cf_autoresize imagepath=&quot;#varDestination#&quot; maxsize=&quot;#Trim(form.maxsize)#&quot; thumbsize=&quot;#Trim(form.thumbsize)#&quot; prefix=&quot;#Trim(form.prefix)#&quot; filefield=&quot;file4&quot; thumbpath=&quot;#Trim(thumbpath)#&quot;>
<!---Outputs the variables #photo# and #thumbnail#--->
<CFQUERY name=&quot;InsertImage4&quot; DATASOURCE=&quot;#datasource#&quot;>
UPDATE Tales
SET Image4='#photo#'
WHERE TalesID=#Val(GetLastTalesID.LastStoryID)#
</CFQUERY>

</CFIF><!----end of if file4 empty---->



<!---5 Image--->
<CFIF Trim(StripCR(Form.File5)) IS NOT &quot;&quot;>
<!---Call CF_AutoResize --->
<cf_autoresize imagepath=&quot;#varDestination#&quot; maxsize=&quot;#Trim(form.maxsize)#&quot; thumbsize=&quot;#Trim(form.thumbsize)#&quot; prefix=&quot;#Trim(form.prefix)#&quot; filefield=&quot;file5&quot; thumbpath=&quot;#Trim(thumbpath)#&quot;>
<!---Outputs the variables #photo# and #thumbnail#--->
<CFQUERY name=&quot;InsertImage5&quot; DATASOURCE=&quot;#datasource#&quot;>
UPDATE Tales
SET Image5='#photo#'
WHERE TalesID=#Val(GetLastTalesID.LastStoryID)#
</CFQUERY>

</CFIF><!----end of if file5 empty---->

<!---6 Image--->
<CFIF Trim(StripCR(Form.File6)) IS NOT &quot;&quot;>
<!---Call CF_AutoResize --->
<cf_autoresize imagepath=&quot;#varDestination#&quot; maxsize=&quot;#Trim(form.maxsize)#&quot; thumbsize=&quot;#Trim(form.thumbsize)#&quot; prefix=&quot;#Trim(form.prefix)#&quot; filefield=&quot;file6&quot; thumbpath=&quot;#Trim(thumbpath)#&quot;>
<!---Outputs the variables #photo# and #thumbnail#--->
<CFQUERY name=&quot;InsertImage6&quot; DATASOURCE=&quot;#datasource#&quot;>
UPDATE Tales
SET Image6='#photo#'
WHERE TalesID=#Val(GetLastTalesID.LastStoryID)#
</CFQUERY>

</CFIF><!----end of if file6 empty---->




</CFIF><!----end of if file size is too large--->

</cflock>
</CFTRANSACTION>
 
I ran into the CR problem with IE on Macs, too. StripCR() doesn't work for them because they use a different character for their carriage return (it's like Chr(10) instead of Chr(13) or something like that). You might want to do a little debugging with CFOUTPUT, Chr() and Asc() to figure out what exact character is being submitted to the server from the Mac, then using ReReplace() to replace the character with nothing (&quot;&quot;). It's a real pain, but it's effective.

Hope this helps you with part of your problem!

inger
 
I had some assistance from the Macromedia forum, the answer was to use <CFTRY> and <CFCATCH>. Thought I share with it anyone running into the same problem.

So my adjusted code would look like such:
<!---1st image--->
<CFTRY><!----MAC IE will throw error, do nothing if it does---->
<CFIF Trim(StripCR(Form.File1)) IS NOT &quot;&quot;>
<!---Call CF_AutoResize --->
<cf_autoresize imagepath=&quot;#UploadNewsImagesDestination#&quot; maxsize=&quot;#Trim(form.maxsize)#&quot; thumbsize=&quot;#Trim(form.thumbsize)#&quot; prefix=&quot;#Trim(form.prefix)#&quot; filefield=&quot;file1&quot; thumbpath=&quot;#UploadNewsImagesThumbnailDestination#&quot;>
<!---Outputs the variables #photo# and #thumbnail#--->
<CFQUERY name=&quot;InsertImage1&quot; DATASOURCE=&quot;#datasource#&quot;>
UPDATE Alumni_News
SET Image1='#trim(photo)#'
WHERE NewsID=#Val(GetLastNewsID.LastStoryID)#
</CFQUERY>

</CFIF>
<cfcatch type=&quot;Any&quot;></cfcatch>
</CFTRY>
<!----end of if file1 empty---->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top