trouble save the image upload in php

删除回忆录丶 提交于 2019-12-12 07:03:08

问题


i have this master page and a web form with the master page the problem i have is that the code wont run or save into the folder i want it to, so how do i change the code in the vb? basically i have a javascript which have a input that allow me to upload a file or image, but the problem, it seem like total skip the code inside

    <script type = "text/javascript">
            var counter = 0;

            function AddFileUpload() {
                var div = document.createElement('DIV');
                div.innerHTML = '<input id="file' + counter + '" name = "file' + counter + '" type="file" /><input id="Button' + counter + '" type="button" value="Remove" onclick = "RemoveFileUpload(this)" />';
                document.getElementById("FileUploadContainer").appendChild(div);
                counter++;
            }
            function RemoveFileUpload(div) {
                document.getElementById("FileUploadContainer").removeChild(div.parentNode);
            }
            $(document).ready(function () {
                AddFileUpload();
            });

        </script>  


<span style ="font-family:Arial">Click to add files</span>&nbsp;&nbsp;

        <br /><br />
        <div id = "FileUploadContainer">
            <!--FileUpload Controls will be added here -->
        </div>
        <br />
        <input id="ButtonAdd" type="button" value="add" onclick = "AddFileUpload()" />
        <asp:Button ID="btnUpload" runat="server" Text="Upload"  />
    <asp:Label ID="lbl2" runat="server" ForeColor="Red"></asp:Label>
        <br />

     Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
            For i As Integer = 0 To Request.Files.Count - 1
                Dim PostedFile As HttpPostedFile = Request.Files(i)
                If PostedFile.ContentLength > 0 Then
                    Dim FileName As String = System.IO.Path.GetFileName(PostedFile.FileName)
                    PostedFile.SaveAs(Server.MapPath("Files\img\") + FileName)

                Else
                    lbl2.Text = "No images have been selected to upload "
                End If
            Next
        End Sub

回答1:


Your question is a bit confusing.. But by the things that i have understood from your question. i would say if u have problem of adding forms into your content form u can remove form from the master page and then u have to add forms to each content form you will add.

Bu if you want multiple forms in your page u can do so by making only one form visible at a time.

But see to it that the form is in another placeholder from the one which already had form in it. Question is a bit confusing but hope i was able to give u solution ...



来源:https://stackoverflow.com/questions/9125460/trouble-save-the-image-upload-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!