Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **the html code attach.html**
- <!DOCTYPE html>
- <!--
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
- -->
- <html>
- <head>
- <script type="text/javascript">
- </script>
- <title>Attach</title>
- </head>
- <body>
- <br />
- <br />
- <br>
- <center>
- <form name="attach" action="./upload_attach.jsp" method="post"
- ENCTYPE="multipart/form-data">
- <p><b>Upload No:</b><input type="text" name=num size=30> </p>
- <p>
- <input type="file" name="attach"/>
- </p>
- <br />
- <br>
- <input type="submit" name="upl" value="UPLOAD">
- </form>
- </center>
- </body>
- </html>
- <%--
- Document : upload_atach
- Created on : 30 janv. 2016, 20:01:08
- Author : Techno
- --%>
- <%@page import="java.io.FileInputStream"%>
- <%--@page contentType="text/html" pageEncoding="UTF-8"--%>
- <!DOCTYPE html>
- <%@ page contentType="text/html;charset=windows-1252"%>
- <%@ page import ="java.sql.*" %>
- <%@ page import ="javax.sql.*" %>
- <%@ page import ="javax.naming.InitialContext" %>
- <%@ page import ="java.sql.PreparedStatement.*" %>
- <%@page import="java.io.File"%>
- <form name="upload1" method=get>
- <%
- try
- {
- int up1=Integer.parseInt(request.getParameter("num"));
- String up2=request.getParameter("attach");
- File f=new File("C:\Users\Techno\Pictures\mc.jpg");
- FileInputStream input= new FileInputStream(f);
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- Connection
- //con=DriverManager.getConnection("jdbc:odbc:bal aji","admin","qsg");
- con=DriverManager.getConnection("jdbc:sqlserver://TECHNOPC\SQLEXPRESS:1433;databaseName=gestion_courrier;user=sayf;password=sayf;");
- PreparedStatement pst=con.prepareStatement("insert into upload values(?,?)");
- pst.setInt(1,up1);
- //pst.setBinaryStream(2,fis,(int)f.length());
- pst.setBinaryStream(2,input);
- pst.executeUpdate();
- pst.close();
- con.close();
- %>
- <center><h3>File Uploaded Successfull</h3></center>
- <%
- }
- catch(Exception e)
- {
- // System.out.println(e.toString());
- e.getMessage();
- %>
- <center><h3>File Does not Uploaded</h3></center>
- <%
- }
- %>
- </form>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement