Click here to Skip to main content
16,009,185 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim ImageBinary() As Byte
    Dim Header1 As Byte, Header2 As String
    Dim BHeader1() As Byte, BHeader2() As Byte, Buffer() As Byte
    Dim boundary As String
    Dim fPath As String, fName As String
    Dim Headers As String
    Dim X As New Collection
    Dim wbody As Byte

    wbody = TextBox1.Text
    fPath = "C:\Users\변형민\Desktop\이미지 업로드\"
    fName = Dir(fPath & "*.jpg")

    Do While Len(fName)
        X.Add(fName, fName)
        fName = Dir$()
    Loop


    boundary = "26036217909135"


    fName = X(Int(Rnd() * X.Count + 1))

    ImageBinary = IO.File.ReadAllBytes(fPath & fName)
    BHeader1 = System.Text.Encoding.Default.GetBytes(Split(wbody, "wBinary")(0))
    BHeader2 = System.Text.Encoding.Default.GetBytes(Split(wbody, "wBinary")(1))

    Dim DS As New MemoryStream
    DS.Write(BHeader1, 0, BHeader1.Length)
    DS.Write(ImageBinary, 0, ImageBinary.Length)
    DS.Write(BHeader2, 0, BHeader2.Length)
    DS.Position = 0
    ReDim Buffer(DS.Length)
    DS.Read(Buffer, 0, Buffer.Length) : DS.Close()
    With WinHttp
        .Open("POST", "http://imgdb.kilho.net/upload.php")
        .SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:43.0) Gecko/20100101 Firefox/43.0")
        .SetRequestHeader("Referer", "http://image.kilho.net")
        .SetRequestHeader("Content-Type", "multipart/form-data; boundary=---------------------------" & boundary)
        .SetRequestHeader("Content-Length", UBound(Buffer))
        .Send(Buffer)
        .WaitForResponse() : Application.DoEvents()
        Headers = .GetAllResponseHeaders
        MsgBox(.ResponseText)

    End With
End Sub


but server message "you don't have permission acess upload.php server"
why..?
Posted
Comments
dan!sh 5-Jan-16 1:44am    
It does not work, because you don't have access to it. Why you don't have access it is something either you or the owner of said server/application can tell.

1 solution

The error message is pretty explicit:
you don't have permission acess upload.php server

The most likely reason is that you aren't the right user: You are trying to access a specific users Desktop, and unless you have elevated permissions or you are that user the system is going to stop you. And since this seems to be web based code, the chances are that it is running under IIS rather than as your user identity.

Instead of trying to save it to a specific user, either have a folder created on the server that everyone can access (dangerous), or use Server.MapPath to access a folder under your website root directory to hold the file(s).
 
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