Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="post" action="signup" enctype="multipart/form-data">
- <input type="text" name="username" placeholder="Username">
- <input type="email" name="email" placeholder="Email">
- <input type="password" name="password" placeholder="Password" >
- <input type="file" name="image">
- <input type="submit" id="submit" style="width:20%; float:right; padding:4px 10px;" value="Se connecter">
- </form>
- String username = "";
- String email = "";
- String password = "";
- String image = "";
- int invitation = 0;
- ArrayList<String> liste = new ArrayList<String>();
- try {
- List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(req);
- for(FileItem item:items){
- if(item.isFormField()){
- if(item.getFieldName().equals("username")){
- username = item.getString();
- System.out.println(username);
- }
- if(item.getFieldName().equals("email")){
- email = item.getString();
- System.out.println(email);
- }
- if(item.getFieldName().equals("password")){
- password = item.getString();
- System.out.println(password);
- }
- }
- else {
- image = item.getName();
- System.out.println(image);
- String imageName = FilenameUtils.getName(item.getName());
- System.out.println(imageName);
- File folder = new File("C:/Users/user/wORKPLce/ImitateBook/WebContent/Assets/images");
- File file = null;
- try {
- file = File.createTempFile("img",imageName,folder);
- }catch(Exception e){
- System.out.println("Error here here");
- }
- liste.add(item.getName());
- item.write(file);
- }
- }
- }
- catch(Exception e){
- System.out.println("Error signup getData");
- }
Add Comment
Please, Sign In to add comment