2021年8月6日 星期五

uploadfile php

 <?php echo  $_FILES["fup"]["name"]; ?><br>

<?php echo  $_FILES["fup"]["size"]; ?><br>

<?php echo  $_FILES["fup"]["type"]; ?><br>

<?php echo  $_FILES["fup"]["tmp_name"]; 

move_uploaded_file($_FILES["fup"]["tmp_name"],"updown/a2.png");

?>


還真容易!

還真容易錯!

1、有updown子目錄?

2、有png檔?

3、move_uploaded_file 不要拼錯

4、$_FILES[]..不是 $_POST[]

5、$_FILES["fup"].,fup外面要加""

6、html與 php中的參數名稱及目錄名稱要一致,updown, upfile, upload都可以,但不可以前後

不一樣

7、updown 與 /updown差一個斜線,會讓你頭大

8、要有目的位置檔案名稱

9、還要去php.ini改upload_max_filesize=5M

10、錯在哪裡?

11、反覆試的耐心

12、找錯誤的細心

13、google 下關鍵字的技巧

14、基本功: 編輯能力、網站概念、網頁概念、程式概念...

15、背景知識:#xamp #php #相對目錄 #網頁間資料傳送 

...

...

有空再補充!...


複製貼上一秒就可以用,恭喜你!

但複製貼上後,又改了10次才成功,恭喜你!有了解決問題的能力!

uploadfile html

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>無標題文件</title>

</head>


<body>

<form action="fup.php" method="post" enctype="multipart/form-data" name="form1" id="form1">

  <label for="fup"></label>

  <input type="file" name="fup" id="fup" />

  <input type="submit" name="submit" id="submit" value="送出" />

</form>

</body>

</html>

LIS 、LCS VB.Net

 Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'in 9 15 7 6 11 12 4 out 9 11 12 ,輸出要求,和最大的LIS 

        Dim ins = "9 15 7 6 11 12 4"

        Dim data1 = ins.Split(separator:=" ", options:=System.StringSplitOptions.RemoveEmptyEntries)

        Dim n = UBound(data1)

        Dim d(n) As Int16

        For i = 0 To n

            d(i) = data1(i)

        Next

        Dim d1(n) As Int16

        d.CopyTo(d1, 0)

        Array.Sort(d1)


        Dim c(n, n)

        Dim cf(n, n)


        For i = 0 To n

            c(i, 0) = 0

            c(0, i) = 0

        Next i

        Dim path As New ArrayList

        For i = 1 To n

            For j = 1 To n

                If d(i) = d1(j) Then

                    c(i, j) = c(i - 1, j - 1) + 1

                    cf(i, j) = 3

                    path.Add(d(i))

                Else

                    c(i, j) = Math.Max(c(i, j - 1), c(i - 1, j))

                    If c(i, j) = c(i, j - 1) Then cf(i, j) = 2

                    If c(i, j) = c(i - 1, j) Then cf(i, j) = 1

                End If

            Next

        Next

        MsgBox(c(n, n))


        Dim ss = ""

        For i = 0 To n

            For j = 0 To n

                ss = ss & c(i, j)

            Next

            ss = ss & vbNewLine

        Next

        MsgBox(ss)


        Dim pathArray = path.ToArray

        lcs(pathArray, cf, n, n)

        MsgBox(sss)

    End Sub


    Dim sss = ""

    Sub lcs(ByVal pathArray, ByVal cf, ByVal i, ByVal j)

        If i = 0 Or j = 0 Then

            Return

        ElseIf cf(i, j) = 3 Then

            lcs(pathArray, cf, i - 1, j - 1)

            sss = sss & pathArray(i - 1) & " "

        ElseIf cf(i, j) = 1 Then

            lcs(pathArray, cf, i - 1, j)

        Else

            lcs(pathArray, cf, i, j - 1)

        End If

    End Sub

End Class






2021年8月3日 星期二

羅馬數字 VB.Net

        

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim rd1 = "I(1)V(5)X(10)L(50)C(100)D(500)M(1000)"
        Dim sep = {"(", ")"}
        Dim rd = rd1.Split(sep, StringSplitOptions.RemoveEmptyEntries)
        Dim d1 As New Dictionary(Of String, Integer)
        For i = 0 To 12 Step 2
            d1.Add(rd(i), CInt(rd(i + 1)))
        Next
        Dim d2 As New Dictionary(Of String, Integer)
        d2.Add("IV", 4)
        d2.Add("IX", 9)
        d2.Add("XC", 90)
        d2.Add("XL", 40)
        d2.Add("CD", 400)
        d2.Add("CM", 900)

        Dim tstr = "IXCDM"
        Dim s = 0
        While tstr.Length > 0
            For Each ds In d2.Keys
                If InStr(tstr, ds) > 0 Then
                    s = s + d2(ds)
                    tstr = tstr.Substring(2)
                End If
            Next
            For Each ds In d1.Keys
                If InStr(tstr, ds) > 0 Then
                    s = s + d1(ds)
                    tstr = tstr.Substring(1)
                End If
            Next
        End While
        MsgBox(s)
        End
    End Sub
End Class

TreeView TreeNode VB.Net

 Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim t(100) As TreeNode


        Dim namedata = {"", "公司", "部門一", "部門二", "分部一", "分部二", "分部一", "分部二", "人員一", "人員二", "人員一", "人員二", "人員一", "人員二"}

        Dim rr(100) As String


        For dist = 0 To 40 Step 20

            For i = 1 + dist To 12 + dist

                rr(i) = namedata(i - dist)

            Next

        Next


        rr(1) = "公司一"

        rr(21) = "公司二"

        rr(41) = "公司三"

        For dist = 0 To 40 Step 20

            t(1 + dist) = TreeView1.Nodes.Add(rr(1 + dist))

            For i = 2 To 12

                t(i + dist) = t(i \ 2 + dist).Nodes.Add(rr(i + dist))

            Next

        Next

        TreeView1.ExpandAll()

    End Sub

End Class



LCS VB.Net

 Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim s1 = {0, 2, 5, 7, 9, 3, 1, 2} ' s1(0) 與s2(0) 未算入

        Dim s2 = {0, 3, 5, 1, 3, 2, 8}

        Dim n = UBound(s1)

        Dim m = UBound(s2)

        Dim t(n, m) As Integer

        For i = 1 To n

            t(i, 0) = 0

        Next

        For i = 1 To m

            t(0, i) = 0

        Next

        For i = 1 To n

            For j = 1 To m

                If s1(i) = s2(j) Then

                    t(i, j) = t(i - 1, j - 1) + 1

                Else

                    t(i, j) = Math.Max(t(i - 1, j), t(i, j - 1))

                End If

            Next

        Next

        MsgBox(t(n, m))

    End Sub

End Class

LIS VB.Net

 Public Class Form1

    Dim s = {1, 6, 3, 4, 8, 5, 2, 7, 9}

    Dim ll(8) As Integer

    Sub lis()

        For i = 0 To UBound(s) 'Ubound = length -1

            ll(i) = 1

        Next

        For i = 0 To UBound(s)

            For j = i + 1 To UBound(s)

                If s(i) < s(j) Then

                    ll(j) = Math.Max(ll(j), ll(i) + 1)

                End If

            Next

        Next

    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        lis()

        MsgBox(ll.Max)

    End Sub

End Class

BFS VB.Net

 Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim fileContents As String

        fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\dfs.txt")

        Dim lines = fileContents.Trim().Split(vbNewLine)

        Dim gdict As New Dictionary(Of String, Array)

        For i = 0 To lines.Length - 1

            Dim cols = lines(i).Split(":")

            Dim sep = {Chr(34), Chr(39), " ", "[", "]", ","}

            Dim nod = cols(0).Trim().Split(sep, StringSplitOptions.RemoveEmptyEntries)

            Dim cnod = cols(1).Split(sep, StringSplitOptions.RemoveEmptyEntries)

            gdict.Add(nod(0), cnod)

        Next


        bfs(visited, gdict, "5")

        MsgBox(ss)

    End Sub


    Dim visited As New ArrayList

    Dim ss = ""


    Sub bfs(ByRef visited, ByRef graph, ByVal nod)

        Dim q As New Queue

        q.Enqueue(nod)

        While q.Count > 0

            Dim s = q.Dequeue()

            ss = ss & s & " "

            For Each neighbor In graph(s)

                If Not visited.contains(neighbor) Then

                    visited.add(neighbor)

                    q.Enqueue(neighbor)

                End If

            Next

        End While

    End Sub

End Class



DFS VB.Net sample

 Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim fileContents As String

        fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\dfs.txt")

        Dim lines = fileContents.Trim().Split(vbNewLine)

        Dim gdict As New Dictionary(Of String, Array)

        For i = 0 To lines.Length - 1

            Dim cols = lines(i).Split(":")

            Dim sep = {Chr(34), Chr(39), " ", "[", "]", ","}

            Dim nod = cols(0).Trim().Split(sep, StringSplitOptions.RemoveEmptyEntries)

            Dim cnod = cols(1).Split(sep, StringSplitOptions.RemoveEmptyEntries)

            gdict.Add(nod(0), cnod)

        Next

        dfs(visited, gdict, "5")

        MsgBox(ss)

    End Sub


    Dim visited As New ArrayList

    Dim ss = ""


    Sub dfs(ByRef visited, ByRef graph, ByVal nod)

        If Not visited.contains(nod) Then

            ss = ss & nod & " "

            visited.add(nod)

            For Each neighbor In graph(nod)

                dfs(visited, graph, neighbor)

            Next

        End If

    End Sub

End Class

dfs.txt
'5' : ['3','7'],
'3' : ['2', '4'],
'7' : ['8'],
'2' : [],
'4' : ['8'],
'8' : [],



2021年8月1日 星期日

VB.Net TreeView TreeNode


 

 Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated

        Dim t(13) As TreeNode

        Dim r = "0,1,2,3,4,5,6,7,8,9,10,11,12".Split(",")

        Dim rr = {"", "公司", "部門一", "部門二", "分部一", "分部二", "分部一", "分部二", "人員一", "人員二", "人員一", "人員二", "十二"}

        t(r(1)) = TreeView2.Nodes.Add(rr(1))

        For i = 2 To 12

            t(i) = t(i \ 2).Nodes.Add(rr(i))

        Next

        TreeView2.ExpandAll()

    End Sub