السلام عليكم ورحمة الله وبركاته
اخوتي الاعزاء عندما برمجة برنامج يقوم بتحميل ملف من قبل المستتخدم الى السيرفر (طبعا عنوان الملف في السيرفر انا احدده)
ففي الحاسبة احدده هو كما يلي
C:\Documents and Settings\Mahmood2010\My Documents\NetBeansProjects\Mobile learning\web\Sheet"
فما هو عنوان الملف الذي يستلم الفايلات المحمله في السيرفر في الانترنت عندما احمل البرنامج على النت (اقصد بالملف هو Sheet )
والبرنامج هو كما يلي طبعا انا واضعة في احد مشاركاتي
<%--
Document : index
Created on : Feb 19, 2010, 11:25:24 PM
Author : Mahmood2010
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ page language="java" import="javazoom.upload.*,java.util.*" %>
<% request.setCharacterEncoding("windows-1256"); %>
<jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
<jsp:setProperty name="upBean" property="folderstore" value="C:\Documents and Settings\Mahmood2010\My Documents\NetBeansProjects\Mobile learning\web\Sheet" />
</jsp:useBean>
<head>
<meta http-equiv="Content-Language" content="ar-sa">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>Upload</title>
<style TYPE="text/css">
<!--
.style1 {
font-size: 12px;
font-family: Verdana;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<ul class="style1">
<%
if (MultipartFormDataRequest.isMultipartFormData(request)) {
// Uses MultipartFormDataRequest to parse the HTTP request.
MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
String todo = null;
if (mrequest != null) {
todo = mrequest.getParameter("todo");
}
if ((todo != null) && (todo.equalsIgnoreCase("upload"))) {
Hashtable files = mrequest.getFiles();
if ((files != null) && (!files.isEmpty())) {
UploadFile file = (UploadFile) files.get("uploadfile");
if (file != null) {
out.println("<li>Form field : uploadfile" + "<BR> Uploaded file : " + file.getFileName() + " (" + file.getFileSize() + " bytes)" + "<BR> Content Type : " + file.getContentType());
}
// Uses the bean now to store specified by jsp:setProperty at the top.
session.setAttribute("fileName", file.getFileName());
upBean.store(mrequest, "uploadfile");
} else {
// out.println("<li>No uploaded files");
// response.sendRedirect("illAccess.jsp");
}
} else {
out.println("<BR> todo=" + todo);
}
response.sendRedirect("finalUploadlearningcourses.jsp");
}
%>
<!-- learning course -->
<table width="240" height="5" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="#3333FF" align="center" width="240" height="5" valign="top" ></td>
</tr>
<tr>
<td align="center" width="240"><img src="image/course.gif" width="236" height="90" align="center"/></a></td>
</tr>
<tr>
<td bgcolor="#3333FF" align="center" width="240" height="5" valign="top" ></td>
</tr>
</table>
<table width="240" border="0" cellspacing="1" cellpadding="1" align="center" class="style1" bgcolor="#99FF99">
<form method="post" action="index.jsp" name="upform" enctype="multipart/form-data">
<tr>
<td align="center" width="240">
<font color="#000099" face="Simplified Arabic"><b><font size="3">
Name of the Learning Course must be in English and Learning Course type word or power point.</b>
</font>
</td>
</tr>
<tr>
<td align="right" width="240">
<p dir="ltr">
<span lang="en-us">
</span>
<input type="file" name="uploadfile" size="10">
</td>
</tr>
<tr>
<td align="center" width="240"><input type="hidden" name="todo" value="upload">
<p dir="ltr">
<span lang="en-us"> </span>
<input type="submit" name="Submit" value="Upload" align="left"></td>
</tr>
</table>
</form>
</center>
</body>
</html>برنامج الذي يتعلق بالسابق ويبين نجاح التحميل
<%--
Document : index
Created on : Feb 19, 2010, 11:25:24 PM
Author : Mahmood2010
--%>
<%@ page language="java" contentType="text/html; charset=windows-1256" pageEncoding="UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FinalUpload</title>
</head>
<center>
<body>
<!-- learning course -->
<table width="240" height="5" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="#3333FF" align="center" width="240" height="5" valign="top" ></td>
</tr>
<tr>
<td align="center" width="240"><img src="image/course.gif" width="236" height="90" align="center"/></a></td>
</tr>
<tr>
<td bgcolor="#3333FF" align="center" width="240" height="5" valign="top" ></td>
</tr>
</table>
<table width="240" height="5" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#99FF99">
<tr>
<td align="center" width="240" valign="top">
<font face="Lucida Calligraphy" size="3" color="#000099">
The
</font>
<% request.setCharacterEncoding("windows-1256"); %>
<%
String fn=(String)session.getAttribute("fileName");
out.print(fn);
// تقوم باستخدام هذا الاسم واضافته بالداتا بيز
%>
</td>
</tr>
<tr>
<td align="center" width="240" valign="top">
<font face="Lucida Calligraphy" size="3" color="#000099">
((Learning Course))<p> Insert successfully.
</font>
</td>
</tr>
</table>
<table width="240" height="5" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#99FF99" >
<tr>
<td align="center" width="240" valign="top"><a href="insertdblearningcourses.jsp" >
<STYLE TYPE="text/css">
A { text-decoration: none; }
A:link { color: #000000; }
A:visited { color: #000000; }
</STYLE>
<font color="#FF0000" size="2">Insert to DB</font></a></td>
</tr>
</table>
</center>
</body>
</html>فارجو معونتكم
اخوتي الكرام
اخوكم
محمود سامي
