are u getting anything from the uploadContent? because i think i should be File file String fileContentType String fileFileName
On Thu, Sep 10, 2009 at 12:50 PM, KIRTI CHOPRA <kirtichopra2...@gmail.com>wrote: > > hi all > i am new to struts and trying to upload a file in struts 2.0 > i am using <s:file> tag and have given simple getter setters in action > class > i am getting null value in file name pls help and let me know how i can do > it. > code is given below: > Action class > > package com.neevtech.newsletter.action; > > import java.io.File; > > /** > * Created by IntelliJ IDEA. > * User: Owner > * Date: Sep 9, 2009 > * Time: 10:22:18 AM > * To change this template use File | Settings | File Templates. > */ > public class UploadXlsAction extends BaseAction { > private File file; > private String uploadContent; > private String fileName; > > public String execute() throws Exception > { > this.file=getFile(); > this.fileName=getFileName(); > /*String filepath=file.getAbsolutePath(); > System.out.println(filepath);*/ > System.out.println(fileName); > return "success"; > } > public File getFile() { > return file; > } > > public void setFile(File file) { > this.file = file; > } > > public String getUploadContent() { > return uploadContent; > } > > public void setUploadContent(String uploadContent) { > this.uploadContent = uploadContent; > } > > public String getFileName() { > return fileName; > } > > public void setFileName(String fileName) { > this.fileName = fileName; > System.out.println(fileName); > } > > public String uploaded(){ > this.file=getFile(); > this.fileName=getFileName(); > System.out.println(fileName); > return "success"; > } > > } > Jsp page > > <%@ taglib prefix="s" uri="/struts-tags"%> > <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%> > > > <div class="centertb"> > > <div class="subTitleText" style="padding-left: 50px;"> > <s:form method="POST" enctype="multipart/form-data" > theme="simple"> > <table width="80%" style="font-weight: normal;"> > <tr> > <td> > <s:file name="file" label="File"></s:file> > </td> > </tr> > <tr> > <td><s:submit action="uploadXls"cssClass="submitButton" > label="upload xls" align="left" cssStyle="margin-left:100px;"/></td> > </tr> > </table> > </s:form> > </div> > </div> > > -- > View this message in context: > http://www.nabble.com/uploading-a-.xls-file-tp25377242p25377242.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >