Fileupload problemi

UI Components for JSF
Post Reply
alp
Posts: 8
Joined: 24 Aug 2010, 23:19

26 Nov 2010, 01:15

netbeans 6.8 glassfish kullanıyorum.

<h:form enctype="multipart/form-data" prependId="false">
<p:fileUpload fileUploadListener="#{FileupdowBean.handleFileUpload}" allowTypes="*.jpg;*.png;*.gif;" description="Images" />
</h:form>
---------------------------------------------
FileupdowBean

@ManagedBean(name="FileupdowBean")
@RequestScoped
public class FileupdowBean {


public FileupdowBean() {
}
public void handleFileUpload (FileUploadEvent event) {

String filename;
UploadedFile upfile = event.getFile();
filename=upfile.getFileName();


byte[] readData=upfile.getContents();
String yol="C:\\" ;
FileOutputStream fos = null;
try {
fos = new FileOutputStream(yol + filename);
} catch (FileNotFoundException ex) {
Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
fos.write(readData);
} catch (IOException ex) {
Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
fos.flush();
} catch (IOException ex) {
Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
fos.close();
} catch (IOException ex) {
Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
}


}
}

fileupload yapamıyorum. web.xml'e herhangi birşey girmeden denedim olmadı.Aşağıdaki şekilde de olamadı.

<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>10240000</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>/temp</param-value>
</init-param>
</filter>

Daha sonra aşağıdakileri ekledim. Bu sefer çalışmadı bile hata verdi.

<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

IE ve google chrome'da denedim.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 65 guests