Guest User

Untitled

a guest
Dec 15th, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <form method="post" action="signup" enctype="multipart/form-data">
  2.  
  3. <input type="text" name="username" placeholder="Username">
  4. <input type="email" name="email" placeholder="Email">
  5. <input type="password" name="password" placeholder="Password" >
  6. <input type="file" name="image">
  7. <input type="submit" id="submit" style="width:20%; float:right; padding:4px 10px;" value="Se connecter">
  8.  
  9. </form>
  10.  
  11. String username = "";
  12. String email = "";
  13. String password = "";
  14. String image = "";
  15. int invitation = 0;
  16.  
  17. ArrayList<String> liste = new ArrayList<String>();
  18.  
  19. try {
  20. List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(req);
  21.  
  22. for(FileItem item:items){
  23. if(item.isFormField()){
  24. if(item.getFieldName().equals("username")){
  25. username = item.getString();
  26. System.out.println(username);
  27. }
  28. if(item.getFieldName().equals("email")){
  29. email = item.getString();
  30. System.out.println(email);
  31. }
  32. if(item.getFieldName().equals("password")){
  33. password = item.getString();
  34. System.out.println(password);
  35. }
  36. }
  37. else {
  38. image = item.getName();
  39. System.out.println(image);
  40. String imageName = FilenameUtils.getName(item.getName());
  41. System.out.println(imageName);
  42. File folder = new File("C:/Users/user/wORKPLce/ImitateBook/WebContent/Assets/images");
  43.  
  44. File file = null;
  45. try {
  46. file = File.createTempFile("img",imageName,folder);
  47. }catch(Exception e){
  48. System.out.println("Error here here");
  49. }
  50.  
  51. liste.add(item.getName());
  52.  
  53. item.write(file);
  54.  
  55. }
  56. }
  57. }
  58. catch(Exception e){
  59. System.out.println("Error signup getData");
  60. }
Add Comment
Please, Sign In to add comment