0

I'm working in a desktop application using javafx. This is my code. The method telechargerImage() is called when the user clicks on the button uploadimage in order to choose an image and then I want to save it in localhost/images. Excuse my english.

private Image imagelog;
@FXML
private ImageView image;
@FXML
private JFXButton uploadimage;

private FileChooser fileChooser = new FileChooser();
private File file = null;

void telechargerImage(ActionEvent event) {
        File file = fileChooser.showOpenDialog(stage);
                if (file != null) {
                    imagelog = new Image(file.toURI().toString());                        
                    image.setImage(imagelog);                          
                }
}
MikaelF
  • 3,518
  • 4
  • 20
  • 33
  • There might be a confusion with your usage of `localhost`. Are you trying to just save the file to a specific directory on your computer (in that case you need to specify a filepath)? Are you trying to connect to a server set up on your computer, possibly via ftp or other? Please provide more details as to what you mean by "save in localhost/images" – MikaelF Feb 11 '17 at 03:51
  • I just want to save the image selected in a specific path – nizar zgolli Feb 11 '17 at 13:47
  • Possible duplicate of [Writing javafx.scene.image.Image to file?](http://stackoverflow.com/questions/27054672/writing-javafx-scene-image-image-to-file) – MikaelF Feb 12 '17 at 04:19

0 Answers0