douchao0358 2013-03-24 17:50
浏览 25

将文件从applet发布到PHP

I have a few questions regarding uploading files to a HTTp request (from an applet). This is what I am following: I am taking a screenshot of the screen using Applet's robot and storing the same on the local file system. The file I have saved on the local file system needs to be uploaded to Apache, eventually to be accessed by PHP.

public void sendBufferedImage(File file, BufferedImage screenImage, String urlPath) throws Exception
        {
             ImageIO.write(screenImage, "GIF", file); // This is to store the file in  
                                   a temp location on the local file system.
                 url = new URL(urlPath);
                 urlcon = (HttpURLConnection) url.openConnection();
                 urlcon.setRequestMethod("POST");
                 urlcon.setDoOutput(true);
                 urlcon.connect();
                 out = new DataOutputStream(urlcon.getOutputStream());
                 out.write(file.getPath().getBytes());
         }

Does this complete writing the file to the HTTP request?

  1. If so, how should reading the HTTP request work to get the file handle out of the byte array written to the HTTP request?
  2. Can a file be written to the HTTP request only via byte array?
  3. A sample of how the php code would look like while getting the file handle out of the HTTP request would help a great deal.

Thanks,

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 个人网站被恶意大量访问,怎么办
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)