Click here to Skip to main content
15,920,468 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, this problem has made me really angry by wasting my whole day trying to figure it out.

My VB.NET server, which is running on my computer (which is portforwarded and definately works) is made from this code (just showing relevant parts):

VB
Do
    Dim response As HttpListenerResponse = Nothing
    Try
        Dim context As HttpListenerContext = listener.GetContext()
        response = context.Response
        Dim responseString As String = Nothing
        Dim bytes = Nothing
        Dim WholeUrl As String = context.Request.Url.ToString
        Dim Host As String = "http://" & Label1.Text & ":8080/"
        Dim UrlRequested As String = Replace(WholeUrl.ToLower, Host, Nothing)
        With UrlRequested
            If .EndsWith(".html") Then
                response.ContentType = "text/html"
            Else
                response.ContentType = "text/php"
            End If
            bytes = IO.File.ReadAllBytes("C:\Users\Rixterz\Desktop\FTP Stuff\" & .ToString)
        End With
        Dim buffer() As Byte = bytes
        response.ContentLength64 = buffer.Length
        Dim output As System.IO.Stream = response.OutputStream
        output.Write(buffer, 0, buffer.Length)
    Catch ex As Exception
    Finally
        If response IsNot Nothing Then
            response.Close()
        End If
    End Try
Loop


The folder C:\Users\Rixterz\Desktop\FTP Stuff contains UploadFile.html:
HTML
<html>
    <head>
        <title>File Upload Form</title>
    </head>
    <body>
        This form allows you to upload a file to the server.
        <form action="get_file.php" method="post">
            Type (or select) Filename: <input type="file" name="uploadFile">
            <input type="submit" value="Upload File">
        </form>
    </body>
</html>


and also get_file.php:
HTML
<html>
    <head>
        <title>Process Uploaded File</title>
    </head>
    <body>
        <?php
            move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], 
            "./uploads/{$_FILES['uploadFile'] ['name']}")
        ?>
    </body>
</html>


Nothing shows up when "Upload File" is clicked, and a full system search of the 'uploaded' file returns nothing. Please help.

-Rixterz
Posted
Comments
karthik Udhayakumar 28-May-14 13:16pm    
Did you put a breakpoint and check if the event is triggered?
[no name] 28-May-14 15:39pm    
Which event? The person accessing the HTML from a web browser receives it fine. But when they click "Upload File", it navigates to get_file.php and nothing happens.

1 solution

I notice this piece of attribute is missing from your form tag in uploadfile.html:
enctype="multipart/form-data"

Read more: http://www.w3schools.com/php/php_file_upload.asp[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900