文件上传为HTML到运行VB.NET服务器的计算机 [英] File upload in HTML to computer running VB.NET server
问题描述
这个问题让我非常生气,浪费了我整整一天的努力来解决这个问题。
我的VB.NET服务器,运行在我的身上计算机(这是移植和确定的工作)是由这个代码(只显示相关部分)制成的:
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):
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
文件夹C:\ Users \ Rixterz \Desktop \FTP Stuff包含UploadFile.html:
The folder C:\Users\Rixterz\Desktop\FTP Stuff contains UploadFile.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>
和get_file.php:
and also get_file.php:
<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
"./uploads/{$_FILES['uploadFile'] ['name']}")
?>
</body>
</html>
单击上传文件时没有显示任何内容,并且上传文件的完整系统搜索不返回任何内容。请帮忙。
-Rixterz
Nothing shows up when "Upload File" is clicked, and a full system search of the 'uploaded' file returns nothing. Please help.
-Rixterz
推荐答案
_FILES [ ' uploadFile'] [' tmp_name' ],
./ uploads / {
_FILES['uploadFile'] ['tmp_name'], "./uploads/{
_FILES ['uploadFile'] ['name']})
?>
< / body >
< / html >
_FILES['uploadFile'] ['name']}") ?> </body> </html>
单击上传文件时没有显示任何内容,并且上传文件的完整系统搜索不返回任何内容。请帮忙。
-Rixterz
Nothing shows up when "Upload File" is clicked, and a full system search of the 'uploaded' file returns nothing. Please help.
-Rixterz
我注意到uploadfile.html中的表单标签中缺少这个属性:
I notice this piece of attribute is missing from your form tag in uploadfile.html:
enctype="multipart/form-data"
阅读更多: http://www.w3schools.com/php/php_file_upload.asp [ ^ ]
这篇关于文件上传为HTML到运行VB.NET服务器的计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!