为什么文件上传不了啊???

我自己本机 上传文件是ok的

别人访问http://172.25.49.35:8080/servlet/login可以正常获得网页
上传文件后也没有报错,就是上传不了

代码如下

login.html是放在apache servlet目录下的

<html>
 <head>
  <title align="center">Welcome to the Share PPT Home ! </title>
 </head>
<body> 
 <h3 align="center">welcome to the share PPT Center</h3>  
  <form action = "http://172.25.49.35:8080/servlet/login"
  method="get">
<div align="center">
  上传者 ID 
  <input type="text" name="OwnerID" size ="9"/>
  <br>
   
  作者Author
  <input type="text" name="Author" size ="9"/>
  <br>
   
  Permission
<input type ="radio" name="Permission" value="0" checked/>共享 
<input type="radio" name="Permission" value="1"/>仅好友可见 
  <input type="radio" name="Permission" value="2"/>仅自己可见 
  <br>
   
  选择要上载的文件 
  <input type="file" name="filename" >
  <br>
  <input type="submit" value="上载" >
  </div>
   
</form>
</body>
</html>

login.java


import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
import javax.servlet.*;
import javax.servlet.http.*;
import DB.InsertFile;
import DB.InsertUser;

//upload a ppt or something else
public class login extends HttpServlet{

/**
* @param args
*/
public void doGet(HttpServletRequest request , HttpServletResponse response)
throws ServletException,IOException
{
String OwnerIDstr = request.getParameter("OwnerID").trim();//Owner name
String Author = request.getParameter("Author").trim();
String Permissionstr = request.getParameter("Permission");
String filename = request.getParameter("filename");
response.setContentType("text/html");
//PrintWriter out = response.getWriter();
if(OwnerIDstr.length()==0 || Author.length()==0 || filename.length()==0)
{
//out.println("please complete the infomation ! ");
return;
}
int Permission = Integer.parseInt(Permissionstr);
int OwnerID = Integer.parseInt(OwnerIDstr);
File file = new File(filename);
int index;
for(index=filename.length()-1;index>=0;index--)
{
if(filename.charAt(index)=='//')
break;
}

String newName = filename.substring(index+1);
String a = new String(newName);
/*testout.write("a" + newName);*/
try 
{  
InsertFile file1 = new InsertFile(OwnerID,newName,Author,Permission);
boolean flag = file1.insert();
DataInputStream input=new DataInputStream(
new FileInputStream(filename));  
int r;
String dirurl = "D://Program Files//Apache Software Foundation//Tomcat 7.0 //webapps//servlet//PPT//" + OwnerID;
/*testout.write(dirurl);*/
File dir = new File(dirurl);
//out.write("mkdir:" + dir.mkdir());
DataOutputStream tofile=new DataOutputStream(
new FileOutputStream(dirurl+"//"+newName));

while((r=input.read())!=-1)
{
//out.write((byte)r);
tofile.write((byte)(r));
}
input.close();
//out.close();
tofile.close();

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub

}

}

 为什么别人的文件上载不了呢,是我这边访问不到他们的文件吗?
 求高人指点啊~~~
 本人刚刚开始自学网页制作,是想做一个ppt在线共享网站,可是现在连文件都上传不了,急啊~~~~

 另外谁可以讲讲jsp是什么啊?java+apache就是jsp了吗?

 求教~~~ 

文件上传漏洞是一种常见的网络安全漏洞,它允许攻击者将恶意文件上传到目标服务器上。这种漏洞通常存在于Web应用程序中,攻击者可以通过绕过应用程序的文件上传验证机制,将恶意文件上传到服务器上,并在后续的攻击中执行该文件。 文件上传漏洞可能导致以下安全问题: 1. 执行恶意代码:攻击者可以上传包含恶意代码的文件,如Webshell(用于远程控制服务器)、木马程序等。一旦成功执行,攻击者可以获取服务器的控制权,进而进行其他恶意活动。 2. 数据泄露:攻击者可以上传包含敏感信息的文件,如数据库备份文件、配置文件等。这些文件可能包含用户名、密码、API密钥等敏感信息,一旦泄露,可能导致严重的安全后果。 3. 服务器资源滥用:攻击者可以上传大型文件或大量文件,导致服务器资源被滥用,如磁盘空间耗尽、带宽消耗等,从而影响正常的服务运行。 为了防止文件上传漏洞的发生,开发人员应该采取以下措施: 1. 文件类型验证:限制上传文件的类型和扩展名,只允许上传安全的文件类型。 2. 文件内容验证:检查上传文件的内容,确保其符合预期的格式和结构。 3. 文件名处理:对上传文件的文件名进行过滤和处理,防止恶意文件名的利用。 4. 文件存储位置:将上传的文件存储在安全的位置,并设置适当的访问权限,防止恶意文件的执行。 5. 安全配置:确保服务器和应用程序的安全配置,如禁用不必要的文件上传功能、限制上传文件大小等。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值