CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 file upload problem Help pls JSP/JAVA

Print topic Send  topic

Author Message
Kisat

Posts: 4
Posted: 07/07/2008, 12:09 AM

I can

File file = new file ("d:/new.jpg ")

and insert into oracle db

but now I want to select jpg than insert into my oracle db

<input type="file" name="uploadfile"> - like that

but I can't get location and get file. how I do pls help
View profile  Send private message
sarrivillaga


Posts: 10
Posted: 07/07/2008, 10:54 AM

You should implement a different servlet, and use it to read the file from the database and send it through the http response.

In your pages you shoud call your image like that:

<input type="file" name="uploadfile" src="getImage?imageid">





View profile  Send private message
Kisat

Posts: 4
Posted: 07/07/2008, 7:50 PM

My Jsp page:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/taglibs.jsp" %>

<stripes:layout-render name="/themes.jsp" pageTitle="Content">
<stripes:layout-component name="t.jsp">
<stripes:form action="/upload.action">
<br>
<fieldset>
<stripes:label for="">Pic name</stripes:label>
<br>
<input type="file" name = "pic">

<stripes:submit name="insert" value="add" />
</fieldset>
</stripes:form>
</stripes:layout-component>
</stripes:layout-render>


java page :__________________________________


@UrlBinding("/upload.action")
public class UploadBean extends CrimeActionBean {

private File pic;
........
public Resolution insert() {

BaseDAO myConn = new BaseDAO();
Connection conn = null;

conn = myConn.getConnection();
PreparedStatement ps = null;

try {

File file = new File(getPic().getPath()); - this is my my problem. I can't get file and file location. If I can get file than I will be insert into my Db. How do i decide this problem.

System.out.println(" location " + getPic().getPath());

FileInputStream fis = new FileInputStream(file);
ps = conn.prepareStatement("insert into pics(byrtgelId, pic) values (?,?)");
ps.setInt(1, 121212);
ps.setBinaryStream(2, fis, (int) file.length());
ps.executeUpdate();
ps.close();
fis.close();

} catch (Exception e) {
System.out.println("file upload exception: " + e.getMessage());
}
return new RedirectResolution("/upload.action");
}

.......
}



View profile  Send private message
matheus

Posts: 386
Posted: 07/14/2008, 5:27 AM

Where is Codecharge relationship?
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.