commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pawson, David" <David.Paw...@rnib.org.uk>
Subject fileupload issue
Date Mon, 08 Nov 2004 15:37:57 GMT

I'm running tomcat 5.0.27, with fileupload.

Currently testing on windows 2000, with a production target of Linux.

Given a windows file, with a name containing spaces
'my documents/file.ext' I'm presuming Linux may well cough
at creating such a file.

Is there a way of uploading the file (with spaces)
and then writing the file with, say, spaces replaced
with underscore?


I'm currently using

	String fileName = fn;
	if (fileName.indexOf(" ") != -1)
	    fileName ="'"+fileName+"'"; // quote if holds spaces

	File uploadedFile = new File(AreaDir +sd.pathsep +fn);
	
	if ((uploadedFile.exists() && sd.overwrite) ||
	    (!uploadedFile.exists()))
	{
	    if ((uploadedFile.exists() && sd.overwrite)){
		logger.info(userName + "file overwrite on " + fn);
		//Send email too. FIXME
	    }

	    try {
		item.write(uploadedFile);
	    } catch (java.lang.Exception err) {
		retval= sd.fileWriteError;//failed upload
		logger.error(userName+
			     "Error on writing file to the archive. " + err);
	    }//end catch
	}
	else {
	    retval = sd.fileExistsError; //file exists
	    }
	return retval;


I can't see how I can intercept the filename
to make the changes needed?



Regards DaveP.

**** snip here *****

-- 
DISCLAIMER:

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged.  If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system.

RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants.  However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent
those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message