Upload File -> Add filename to database

Discussion in 'Databases' started by sanjay2409, May 13, 2011.

  1. Hi thanks for all the support that I've had so far.

    Stuck on a slight problem,

    I used the tutorial on how to upload images from here:

    http://support.Winhost.com/KB/a678/persits-aspupload-sample-code.aspx?KBSearchID=289554

    But now I a little confused on how to gather the filename so I can then enter in the details into the database. I have previously been able to add/edit/delete from ms database.

    It's just about how to get that initial filename.

    Many thanks again
    Sanjay
    ps: Winhost IS AMAZING AND SO ARE THE PEOPLE ON Winhost'S FORUM!
     
    Last edited by a moderator: Oct 14, 2015
  2. Thanks, that's very helpful. BUT... it writes the entire path:

    Code:
    <HTML> 
    <BODY> 
    <% 
    Set Upload = Server.CreateObject("Persits.Upload") 
    count = upload.savevirtual ("/aspupload") 
    Response.Write Count & " file(s) uploaded" 
    %> 
    
    <%
    For Each File in Upload.Files
    Response.Write File.Name & "= " & File.Path & ""
    Next
    %>
    
    </BODY> 
    </HTML>

    and I get in return:

    1 file(s) uploadedfilename= E:\web\sanjaypa\aspupload\_52584941_109698042.jpg

    But I am just after the file name... so excluding the E:\web\sanjaypa\aspupload\

    any thoughts?
     
  3. Im sorry, Im confused.

    What happens when you try:

    <%
    For Each File in Upload.Files
    Response.Write File.Name
    Next
    %>
     
  4. If I have:



    Code:
    <%
    For Each File in Upload.Files
    Response.Write File.Name
    Next
    %>
    Then I would have in response
    "1 file(s) uploadedfilename"

    When looking at the code (in dreamweaver)...

    File.Name
    File and Name are both purple
    where as...
    File.Path
    File is purple and Path is in black

    Any thoughts?
     
  5. Per the documentation, it appears that "filename" in "1 file(s) uploadedfilename" would be the name of the file uploaded. Is "filename" the name of the file you uploaded? Do you have a link to this so we can look at?
     
  6. Unfortunately it was the not. The file-name that was uploaded was not called "filename".

    The reason why it is "1 file(s) uploadedfilename"

    is because I didn't put a break line between the two codes writing out.

    here's the link anyways

    http://www.sanjaypatel.co.uk/examples/aspupload.asp
     
  7. Can you post your solution so I can download it and look at the look at the source etc?
     
  8. upload.asp
    Code:
     
    <html> 
    <head> 
    </head> 
    <body bgcolor="#ffffff"> 
        <form action="aspupload1.asp" method="post" enctype="multipart/form-data"> 
            <input type="file" size="40" name="filename" /> 
            <br /> 
            <input type="submit" value="Upload!" /> 
        </form> 
    </body> 
    </html> 

    aspupload1.asp
    Code:
    <HTML> 
    <BODY> 
    <% 
    Set Upload = Server.CreateObject("Persits.Upload") 
    count = upload.savevirtual ("/aspupload") 
    Response.Write Count & " file(s) uploaded" 
    %> 
    
    <%
    For Each File in Upload.Files
    Response.Write File.Name
    Next
    %>
    
    </BODY> 
    </HTML>
    Still not found a solution
     
  9. Ray

    Ray

    I'm thinking for something like this you'll need to capture the File.Path string and then use some "string functions" to start from the right and only display the letters until it hits the character "/". Try looking at this link.
    http://www.aspwebpro.com/aspscripts/functions/string.asp
     

Share This Page