Any guide on how to delete the uploaded file? Any best practice?
Or I will just use the java io? //////////////// Java Delete using io //////////////// String fileName = "file.txt"; // A File object to represent the filename File f = new File(fileName); // Make sure the file or directory exists and isn't write protected if (!f.exists()) throw new IllegalArgumentException( "Delete: no such file or directory: " + fileName); if (!f.canWrite()) throw new IllegalArgumentException("Delete: write protected: " + fileName); // If it is a directory, make sure it is empty if (f.isDirectory()) { String[] files = f.list(); if (files.length > 0) throw new IllegalArgumentException( "Delete: directory not empty: " + fileName); } // Attempt to delete it boolean success = f.delete(); if (!success) throw new IllegalArgumentException("Delete: deletion failed"); ////////////// Upload File ////////////////// Java Class public class Index { @Property private UploadedFile file; public void onSuccess() { File copied = new File("C:/temp/" + file.getFileName()); file.write(copied); } @Persist(PersistenceConstants.FLASH) @Property private String message; Object onUploadException(FileUploadException ex) { message = "Upload exception: " + ex.getMessage(); return this; } } Template <t:form> <t:errors/> <input t:type="upload" t:id="file" validate="required"/> <br/> <input type="submit" value="Upload"/> </t:form> -- View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Deletion-of-the-uploaded-file-tp4405584p4405584.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org