doujianwan7570 2014-10-10 01:17
浏览 41
已采纳

在win 7上的特定文件夹中创建新文件时执行批处理文件

Let me first describe where I am. For readability, that will take three paragraphs.

Original Problem: I am working on a php website, one function of which is to read data from a Word file users upload and then insert the entry into some database. Note: the server is running windows (devil windows!).

My Solution: Write a java program to do the word file reading and database inserting stuff, using java Apache POI library. Then execute the java program in one bat file. Then new problem occurs...

New Problem: How can we make a specific bat file run on a specific file system event? In my case, the event will be file creation in one assigned folder.

Wish I have made myself totally understood. Waiting for your help. Any suggestion is appreciated.

  • 写回答

1条回答 默认 最新

  • dongzhang1987 2014-10-10 01:25
    关注

    If I were you, I would implement some kind of scheduled task(http://technet.microsoft.com/en-us/library/cc772785%28WS.10%29.aspx) on the server that runs the Java app you have for adding the files. Depending on your traffic, you could set it to run every 5 minutes, or every 5 hours, or whatever.

    That Java app would then do this:

    1. Look at that directory

    2. If it sees some file(s), loads the file(s) into the database

    3. When it is finished loading the files, it would delete them from the directory (so it doesn't add them the next time the task executes).

    At the same time, I'm surprised you're not implementing something with PHP through the web app. If your website is already in php, wouldn't it make sense to keep this application logic as part of the PHP stuff as well? To each their own.

    If you went the php route, a super simple approach would be this:

    • have some page submit_doc.php with a form where users can upload a doc

    • when they hit the submit button, some other php file would execute, say upload_doc.php

    • upload_doc.php would handle connecting to the db and adding the file to the db

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)