Re: File Image Upload

2017-07-01 Thread Tobias Soloschenko
Hi, 

there has been a change that the file parts have to be parsed before read:

https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+7.0#MigrationtoWicket7.0-FilePartsmustbeparsedexplicitlybeforetryingtoreadthemWICKET-5839

I don't see this in your code. Could you try this?

kind regards

Tobias

> Am 01.07.2017 um 15:12 schrieb gasper :
> 
> Hello,
> 
> I am trying to upload an image to a particular folder in my Web
> application
> I am using Apache Wicket 6.x
> 
> This is a sample code i am using from MkYong:
> 
> private FileUploadField fileUpload;
>private String UPLOAD_FOLDER = "C:\\";
>//I want to change the UPLOAD_FOLDER from C directory to my folder
> on the webApplication
> 
>public FileUploadPage(final PageParameters parameters) {
> 
>add(new FeedbackPanel("feedback"));
> 
>Form form = new Form("form") {
> @Override
> protected void onSubmit() {
> 
>final FileUpload uploadedFile = fileUpload.getFileUpload();
>if (uploadedFile != null) {
> 
>// write to a new file
>File newFile = new File(UPLOAD_FOLDER
>+ uploadedFile.getClientFileName());
> 
>if (newFile.exists()) {
>newFile.delete();
>}
> 
>try {
>newFile.createNewFile();
>uploadedFile.writeTo(newFile);
> 
>info("saved file: " + uploadedFile.getClientFileName());
>} catch (Exception e) {
>throw new IllegalStateException("Error");
>}
> }
> 
>}
> 
>};
> 
>// Enable multipart mode (need for uploads file)
>form.setMultiPart(true);
> 
>// max upload size, 10k
>form.setMaxSize(Bytes.kilobytes(10));
> 
>form.add(fileUpload = new FileUploadField("fileUpload"));
> 
>add(form);
> 
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/File-Image-Upload-tp4678176.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 


File Image Upload

2017-07-01 Thread gasper
Hello,

I am trying to upload an image to a particular folder in my Web
application
I am using Apache Wicket 6.x

This is a sample code i am using from MkYong:

private FileUploadField fileUpload;
private String UPLOAD_FOLDER = "C:\\";
//I want to change the UPLOAD_FOLDER from C directory to my folder
on the webApplication

public FileUploadPage(final PageParameters parameters) {

add(new FeedbackPanel("feedback"));

Form form = new Form("form") {
 @Override
 protected void onSubmit() {

final FileUpload uploadedFile = 
fileUpload.getFileUpload();
if (uploadedFile != null) {

// write to a new file
File newFile = new File(UPLOAD_FOLDER
+ uploadedFile.getClientFileName());

if (newFile.exists()) {
newFile.delete();
}

try {
newFile.createNewFile();
uploadedFile.writeTo(newFile);

info("saved file: " + 
uploadedFile.getClientFileName());
} catch (Exception e) {
throw new 
IllegalStateException("Error");
}
 }

}

};

// Enable multipart mode (need for uploads file)
form.setMultiPart(true);

// max upload size, 10k
form.setMaxSize(Bytes.kilobytes(10));

form.add(fileUpload = new FileUploadField("fileUpload"));

add(form);

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/File-Image-Upload-tp4678176.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org