[Seasar-user:10959] Re: uploadfile
=?GB2312?B?wO7A1g==?=
[E-MAIL ADDRESS DELETED]
2007年 10月 11日 (木) 19:15:57 JST
----------------------------------------page-----------------------------------------------------
package jp.wess.web.entrcdApply;
public class EntrcdObjectListPage extends BaseGridPage {
private UploadedFile applyFile;
public String doPaging() {
super.setLimit(2);
applyNoDto.setOffset(super.getNewOffset());
applyNoDto.setLimit(super.getLimit());
if ("apply".equals(flag)) {
applyTargetInfoItems =
getEntrcdTargetInfoDao().getTargetInfoList(applyNoDto);
super.setCount(applyNoDto.getCount());
} else {
reissueTargetInfoItems =
getEntrcdReissueTargetInfoDao().getList(applyNoDto);
super.setCount(applyNoDto.getCount());
}
return null;
}
public String doApplyUpload() throws IOException {
String name = applyFile.getName();
long size = applyFile.getSize();
System.out.println(name);
System.out.println(size);
InputStream in = null;
OutputStream out = null;
String path = "D:\\aaa.txt";
in = applyFile.getInputStream();
out = new FileOutputStream(path);
int read = 0;
int byteLength = applyFile.getBytes().length;
byte[] buffer = new byte[byteLength];
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
out.close();
in.close();
// long fileSize1 = applyFile.getSize();
try {
applyFile.getBytes();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
----------------------------------------html-----------------------------------------
<form id="form">
<x:inputFileUpload
id="applyFile" name="applyFile" style="display:none"
value="#{entrcdApply_entrcdObjectListPage.applyFile}"
/>
<input type="submit" class="button large" value="¥¢¥Ã¥×¥í©`¥É"
onclick="uploadfile('doApplyUpload','applyFile')" id="doApplyUpload"/>
-------------------------------------------------JavaScript-----------------------------------
function uploadfile(btna, btnb) {
var buttona = document.getElementsByName(btna);
var buttonb = document.getElementByName(btnb);
buttonb.click();
}
參貧。
2007/10/11, Shinpei Ohtani <[E-MAIL ADDRESS DELETED]>:
>
> Hi,
>
> Let me see your page class and html.
>
> 2007/10/11, 川赤 <[E-MAIL ADDRESS DELETED]>:
> > I want to upload file,but i don't want to display the inputtext and
> button
> > as system designed ,so i hiddened it .
> > I'd like to place a button to call the uploadfile button which is
> hidden.
> >
> > My code is like this:
> >
> > <x:inputFileUpload
> > id="applyFile" style="display:none" name="applyFile"
> > value="#{Apply_ListPage.applyFile}"
> > />
> > <input type="submit" name="applyupload" value="¥¢¥Ã¥×¥í©`¥É"
> > onclick="uploadfile('doApplyUpload','applyFile')"
> > id="doApplyUpload"/>
> >
> >
> > function uploadfile(btna, btnb) {
> >
> > var buttona = document.getElementsByName(btna);
> > var buttonb = document.getElementsByName(btnb);
> > buttonb.click();
> > }
> > It doesn't work. Why?
> >
> > Is there any other way to achieve my goal.
> > _______________________________________________
> > Seasar-user mailing list
> > [E-MAIL ADDRESS DELETED]
> > https://ml.seasar.org/mailman/listinfo/seasar-user
> >
> >
>
>
> --
> =============================
> Shinpei Ohtani
> [E-MAIL ADDRESS DELETED]
> =============================
>
> _______________________________________________
> Seasar-user mailing list
> [E-MAIL ADDRESS DELETED]
> https://ml.seasar.org/mailman/listinfo/seasar-user
>
>
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
URL: http://ml.seasar.org/archives/seasar-user/attachments/20071011/8946b37a/attachment.html
Seasar-user メーリングリストの案内