Results 1 to 4 of 4
  1. #1
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Unhappy how to specify location where uploaded files to be saved on server?

    i was able to upload file from form and it was saved in my drive D: but when i change the location from "D:" to "./template" the upload will fail and i get "An error occurred when...." the webserver has "WebContent" folder and inside it has "template" folder. my understanding to String dirName = "D:"; is that when the client executes fileupload the file will just be moved to his computer's drive D: and not on the server, i want it in the server's "template" folder.. please see the code below

    if (fileItem.getSize() > 0){
    if (optionalFileName.trim().equals("")):confused:
    fileName = FilenameUtils.getName(fileName);
    else
    fileName = optionalFileName;

    String dirName = "D:";

    File saveTo = new File(dirName + fileName);
    try {
    fileItem.write(saveTo);
    %>

    <b><font color=green>The uploaded file has been saved successfully.</font></b>

    <%
    }
    catch (Exception e){
    %>

    <b><font color=red>An error occurred when we tried to save the uploaded file.</font></b>

    <%

  2. #2
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default

    ops :D when i was able to get another pc and test the file upload on the client.. the uploaded file was stored in servers drive D: and not on the client. so problem solved tnx :D

  3. #3
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default

    now i have another problem, after the files have been uploaded example a.doc, the client will still not be able to access it because it seems that the web server didn't know its presence so i have to manually refresh it by pointing to my web project, right-click and hit refresh.. is there a way that it will automatically refresh it once upload is done?

  4. #4
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default

    woot :D eclipse has auto-refresh function :D (solved again)

Similar Threads

  1. how to specify location of file to be uploaded?
    By anthrax in forum New To Java
    Replies: 11
    Last Post: 01-13-2010, 03:48 PM
  2. location provider returns no location
    By sandeeprao.techno in forum CLDC and MIDP
    Replies: 0
    Last Post: 09-24-2009, 10:54 AM
  3. How to use FTP to read files from server?
    By user12345 in forum New To Java
    Replies: 1
    Last Post: 03-18-2009, 01:46 PM
  4. Fetch files over web server
    By Juuno in forum Networking
    Replies: 3
    Last Post: 02-19-2009, 03:02 PM
  5. Saved files are coming back as read-only
    By Manoeuvre in forum Eclipse
    Replies: 0
    Last Post: 11-21-2008, 06:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •