Uploading from Mac or Nescape 6.x

JFile provides limited support for file transfers from a Mac client system running IE 5.0 or above and for Windows/Unix/Linux running Netscape 6.x (JFile will not work with Mac/Netscape).

Upload Limitations for Mac with IE and Windows/Unix/Linux with Nescape 6.x

The only transfer method available with Mac/IE is sockets. URLConnection does not work properly with Netscape 6.x.  Therefore, JFile on a Mac or Netscape 6.x,

MacOS and Netscape 6.x do not support JSObject. Therefore, JFile on these client systems,

Connection methods with Mac+IE or Win/Unix/Linux+Netscape 6.x uploads

When uploading from a Mac+IE or Win/Unix/Linux+Netscape 6.x client system, the connection method will automatically be set to sockets. You cannot use the transfer methods WinInet and URLConnection with these client systems.

See also Transfer Methods.

Displaying Results with Mac+IE, Win/Unix/Linux+Netscape 6.x Uploads, or Sun JVM

If you wish to display the result of an upload from these client systems, you must set the NoJSObjectSupportPostURL parameter. 

For uploads from client systems which support the JSObject (such as Windows/Unix/Linux and IE or Netscape 4.7x), the response from the server is received by the applet and then passed to the JSObject which outputs the response.  However, Mac systems, Netscape 6.x, and Sun's JVM do not support the JSObject.  Although the applet has received the response, it does not have an inherent way to display it.  Therefore, you must provide a separate upload processing page for these uploads which, rather than outputting html to the browser, writes the response to a file in a virtual directory on the server.  This processing script then sends a 302 redirection to the generated file's URL (using "response.redirect").  The applet is then able to get the file containing the response and display it.

If you wish to support users with various operating systems and browsers, you should set both the PostURL and the NoJSObjectSupportPostURL parameters.  If the client system supports JSObjects, only PostURL will be used.  If the client system does not support JSObjects, and the NoJSObjectSupportURL is not set or is set incorrectly, PostURL will be used and no response will be displayed.

Note: The response file which is dynamically generated on the server will not be automatically deleted.  It is recommended that you include the date/time in the filename and create your own process for periodically cleaning out these files.  (Our sample alternative upload processing page,  "formrespAlt.asp" in JFile's Samples\Upload\BrowserNeutral directory provides an example of how to write the response file and name it with a timestamp.)

Filename Modification when Uploading from Mac to Windows

Macs (and certain other platforms) can upload files with names which may contain certain characters (such as "\", "/", ">", "*") which are not allowed for Windows filenames.  This can cause problems when uploading to a Windows server.  Therefore, JFile will, by default, remove these forbidden characters and replace them by "_" or by "_-_" for the "%2f" character ("/" or "|") to keep the same name length.

These modifications will also apply to zip transfers.

If you wish to prevent the original filenames from being modified, set the RemoveWinForbiddenChars parameter to "0".

Jar file for Mac/IE Uploads

In order to run JFile on a Mac system, the jar file which has been signed for use on a Mac must be referenced in the applet tag.  You can find this jar file in the MAC_JAR directory in the JFile installation folder. 

Exercise 7: JFile upload with Mac and Netscape 6.x support

  1. If you created the physical and virtual JFileScripts directories in a previous lesson, go to Step 4. If you did not create the directories, go to Step 2.

  2. Create a directory called JFileScripts and copy the file formresp.asp to this directory. Formresp.asp is a server-side upload processing script that you will find in JFile's Samples\Upload\simple directory (installed by default at C:\Program Files\SoftArtisans\JFile). Formresp.asp uses SoftArtisans FileUp to process the upload.

  3. Copy filetransfer.jar (for non-Mac Netscape) and filetransfer.cab (for non-Mac Internet Explorer) to the directory JFileScripts. These files are in JFile's installation directory (by default, C:\Program Files\SoftArtisans\JFile).  Create a subdirectory in JFileScripts called MAC_JAR.  Copy  Mac_filetransfer.jar from the MAC_JAR directory in JFile's installation directory into the MAC_JAR directory in JFileScripts

  4. Copy the file formrespAlt.asp to the JFileScripts directory.  FormrespAlt.asp is a server-side upload processing script for uploads from client systems with no JSObject support which you will find in JFile's  Samples\Upload\BrowserNeutral directory (installed by default at C:\Program Files\SoftArtisans\JFile).   FormrespAlt.asp uses SoftArtisans FileUp to process the upload, and SoftArtisans FileManager (which comes bundled free with FileUp) to dynamically write the results to a file on the server.   If you look at formrespAlt.asp you will notice that it does not contain any straight HTML or response.write lines.  All HTML is written to the response file on the server.  The last line in the processing script redirects the applet to the results page, using "response.redirect strFileURL", with strFileURL representing the virtual path to the response file. 

  5. Create a virtual directory called JFileScripts and map it to the physical JFileScripts you created in step 1:

    1. Open the Internet Information Services (IIS) explorer.
    2. Right-click Default Web Site.
    3. Select New -> Virtual Directory.
    4. For Alias, enter JFileScripts.
    5. Browse to the JFileScripts directory you created in step 1.
    6. Check "Read" and "Run scripts."
    7. Click "Finish."

  6. Create an HTML script containing the following lines. Name the script BrowserNeutral.htm and save it in your JFileScripts directory.

    
     <!-- Javascript script detects the browser and generates the appropriate applet tag.  
    If the client is Mac/IE, we set the applet's codebase to '/JFileScripts/MAC_JAR', the directory 
    containing the Mac/IE version of filetransfer.jar.  If the client is NOT Mac/IE, we set the codebase 
    to '/JFileScripts', the directory that contains the non-Mac filetranfer.jar and filetransfer.cab. -->
    <SCRIPT LANGUAGE= "JavaScript">
    if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") !=  -1 ) 
    	{ 
    	document.write("<APPLET CODEBASE = '/jfilescripts/MAC_JAR' code= 'softartisans.filetransfer.UploadClient.class'"); 
    	document.write("height='250' width='300' archive='Mac_filetransfer.jar' mayscript name= 'fileupload'>"); 
    	}
    else 
    	{
    	document.write("<APPLET CODEBASE='/jfilescripts' code='softartisans.filetransfer.UploadClient.class'");
    	document.write("height='250' width='300' archive='filetransfer.jar' mayscript name= 'fileupload'>");
    	}
    </SCRIPT> 
    	
    	<!-- The Cabbase parameter specifies the cab file containing the applet for PC/IE clients. -->
    	<PARAM name="cabbase" value="filetransfer.cab">
    
    	<!-- The PostURL parameter specifies the URL to which the file will be posted. -->
    	<PARAM name="PostURL" value="http://localhost/jfilescripts/formresp.asp">
    	
    	<!-- The NoJSObjectSupportPostURL parameter specifies the URL to which the file will be posted if uploaded from a Mac+IE
    	or Windows/Unix/Linux+Netscape 6.x client system. -->
    	<PARAM name="NoJSObjectSupportPostURL" value="http://localhost/jfilescripts/formrespAlt.asp">
    	
    	<!-- The "UseAppletInBrowser" parameter will embed the applet in the page -->
    	<PARAM name="UseAppletInBrowser" value="1">
    	
    	<!-- The FileName# parameter specifies a file to transfer.  When uploading more than one file, use
    	"FileName1," "FileName2," etc. --> 
    	<PARAM name="FileName1" value="c:\boot.ini">
    	
    </APPLET>
  7. To run the script, open the browser, and enter the URL http://localhost/jfilescripts/browserneutral.htm.

Understanding the Script