Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
应用程序引擎(Java)文件上载_Java_Google App Engine_File_Upload - Fatal编程技术网

应用程序引擎(Java)文件上载

应用程序引擎(Java)文件上载,java,google-app-engine,file,upload,Java,Google App Engine,File,Upload,我使用以下示例在App Engine上上传了文件: 及 问题是,我正在提交其他字段以及文件字段,如下所示: <form action="index.jsp" method="post" enctype="multipart/form-data"> <input name="name" type="text" value=""> <br/> <input name="imageField" type="file" size="30"&g

我使用以下示例在App Engine上上传了文件:

问题是,我正在提交其他字段以及文件字段,如下所示:

<form action="index.jsp" method="post" enctype="multipart/form-data">
    <input name="name" type="text" value=""> <br/>
    <input name="imageField" type="file" size="30"> <br/>
    <input name="Submit" type="submit" value="Sumbit">
</form>

为什么会这样?有没有办法检索文本字段值?

您必须通过FileItemIterator。在您提到的示例中,仅处理图像(
FileItemStream-imageItm=iter.next();

有关更多详细信息,请参阅

name = request.getParameter("name");
// From the example: http://stackoverflow.com/questions/1513603/how-to-upload-and-store-an-image-with-google-app-engine-java
FileItemIterator iter = upload.getItemIterator(req);
// Parse the request
while (iter.hasNext()) {
    FileItemStream item = iter.next();
    String name = item.getFieldName();
    InputStream stream = item.openStream();
    if (item.isFormField()) {
        System.out.println("Form field " + name + " with value "
            + Streams.asString(stream) + " detected.");
    } else {
        // Image here.
        System.out.println("File field " + name + " with file name "
            + item.getName() + " detected.");
        // Process the input stream
        ...
    }
}