Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
PeterSmith  
#1 Posted : Wednesday, February 14, 2007 9:40:38 PM(UTC)
PeterSmith

Rank: Member

Groups: Member
Joined: 2/14/2007(UTC)
Posts: 5

I use masterpages. In the masterpage I have defined <form ID="form1" runat="server">.
This way every page the uses my masterpage automatically has a server side form.

I have placed the imageupload control in ImageUpload.aspx (so basically it resides in a server side form).
in ImageUpload.aspx I have defined a normal form: <form id="frm" name="frm">

In there I place the example with the Author input control.
I add the form to the script:

Code:
iu.addParam("AdditionalFormName", "frm");


But my upload.aspx does not receive the value from the "Author" field...

Edited by user Tuesday, December 18, 2007 5:00:13 PM(UTC)  | Reason: Not specified

Alex Makhov  
#2 Posted : Thursday, February 15, 2007 2:28:03 PM(UTC)
Alex Makhov

Rank: Advanced Member

Groups: Member
Joined: 8/3/2003(UTC)
Posts: 998

Hello Peter,

The problem can be in nested forms - ASP.NET server form and the one you have specifed inside. You could use the AddField method to add your field values manually.
Also please send us the link to your page or full page code to find the reason of the problem.

Edited by user Wednesday, February 20, 2008 6:59:08 PM(UTC)  | Reason: Not specified

Sincerely yours,
Alex Makhov

UserPostedImage Follow Aurigma on Twitter!
PeterSmith  
#3 Posted : Sunday, February 18, 2007 4:32:33 AM(UTC)
PeterSmith

Rank: Member

Groups: Member
Joined: 2/14/2007(UTC)
Posts: 5

Hi, ofcourse im glad to send my code for reviewing :-)
notice that I left out the server side dropdown, because I first wanted to make sure that the example you provided would also worked (which still doesnt at the moment)
I try to assign a value to STmp variable, but nothing seems to be sent.


UPLOADIMAGES.ASPX:

Code:
<%@ Page Language="VB" MasterPageFile="~/MyMasterPage.master" AutoEventWireup="false" CodeFile="UploadImages.aspx.vb" Inherits="UploadImages" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CPHContent" Runat="Server">

<div class="UploadPhotosForm">
<br />
    <asp:Panel ID="pnlUploadImages" Visible="false" runat="server">

 
<div class="dialog" style="width:100%;">
 <div class="hdr"><div class="dialogheader">
    <asp:Literal ID="Literal2" runat="server" Text="<%$Resources:gLOSSARY,sELECT %>"></asp:Literal>
 </div><div class="cs"></div></div>
 
 <div class="bdy">
 
  <div class="cs">
   <div class="sc">
    <!-- content area -->
    <b>&nbsp;<asp:Literal Text="<%$Resources:Glossary,BoldFieldsMandatory %>" ID="Literal1" runat="server"></asp:Literal></b>    
    <hr class="dialogruler" />
    
        <div class="FormSection">
            <br />
            <div class="FormFieldSmallName">
                Select an album to upload your photos to:
            </div>
            <div class="FormFieldSmallValue">
<form id="frmextra" name="frmextra">
    Author: <input id="Author" type="text" size="50" value="" name="Author" />
</form>

                
            </div> 
            <br />        
            <div class="FormFieldBigName">
                Total photos in all your photoalbums: <asp:Label ID="lblTotalPhotos" Font-Bold="true" runat="server" Text=""></asp:Label><br />
                Photoslots remaining: <asp:Label ID="lblPhotoSlotsRemaining" Font-Bold="true" runat="server" Text=""></asp:Label><br />
                <br />    
                VIP members have a maximum of <asp:Label ID="lblMaxVIPPhotos" Font-Bold="true" runat="server" Text=""></asp:Label> photos <br /><br />
                
                Allowed extensions: *.jpg;*.jpeg;*.bmp;*.gif;*.jpe<br /><br />                
            </div>
            <br />
            <div class="FormFieldBigName">
<script type="text/javascript">
// Aurigma Image Uploader
//<![CDATA[
//Create JavaScript object that will embed Image Uploader to the page.
var iu = new ImageUploaderWriter("ImageUploader1", 640, 400);



//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "../ImageUploader4.cab";
iu.activeXControlVersion = "4,1,1,0";

//For Java applet only path to directory with JAR files should be specified (without file name).
iu.javaAppletCodeBase = "../";
iu.javaAppletCached = true;
iu.javaAppletVersion = "2.1.1.0";

iu.showNonemptyResponse = "off";

//Configure appearance.
iu.addParam("PaneLayout", "TwoPanes");
iu.addParam("ShowDebugWindow", "true");
iu.addParam("AllowRotate", "false");
iu.addParam("BackgroundColor", "#ccccff");

iu.addParam("UploadSourceFile","false")
iu.addParam("FileMask","*.jpg;*.jpeg;*.bmp;*.gif;*.jpe")


iu.addParam("AdditionalFormName", "frmextra");

//Configure settings. first one is the resized original picture
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "640");
iu.addParam("UploadThumbnail1Height", "480");
iu.addParam("UploadThumbnail1JpegQuality", "60");

//large thumbnail
iu.addParam("UploadThumbnail2FitMode", "Fit");
iu.addParam("UploadThumbnail2Width", "120");
iu.addParam("UploadThumbnail2Height", "120");
iu.addParam("UploadThumbnail2JpegQuality", "65");

//small thumbnail
iu.addParam("UploadThumbnail3FitMode", "Fit");
iu.addParam("UploadThumbnail3Width", "80");
iu.addParam("UploadThumbnail3Height", "80");
iu.addParam("UploadThumbnail3JpegQuality", "55");



//settings for Automatic Upload Recovery 
iu.addParam("FilesPerOnePackageCount", "1");
iu.addParam("AutoRecoverMaxTriesCount", "3");
iu.addParam("AutoRecoverTimeOut", "5000");

//Configure URL files are uploaded to.
iu.addParam("Action", "upload.aspx")

//Configure URL where to redirect after upload.
//iu.addParam("RedirectUrl", "gallery.aspx")

//Tell Image Uploader writer object to generate all necessary HTML code to embed 
//Image Uploader to the page.
iu.writeHtml();
//]]>
	</script>                
	<br /><br />
            </div>
            
        </div>        
    <hr class="dialogruler" />
    
    <!-- content area -->
   </div>
  </div>
 </div>
 <div class="ftr"><div class="cs"></div></div>
</div>

    </asp:Panel>
    
</div>                         
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPHTopMenu" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="CPHMyProfile" Runat="Server">
</asp:Content>





UPLOAD.ASPX.VB

Code:
Imports System.IO
Imports System.Xml
Imports GlobalFunctions

Partial Class upload
    Inherits System.Web.UI.Page
    'This variable specifies relative path to the folder, where the gallery with uploaded files is located.
    'Do not forget about the slash in the end of the folder name.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim UserCode As Integer = Profile.UserCode
        Dim galleryPath As String = "Data/Users/Photos/" + determineDirectoryInterval(UserCode) + "/"
        'how many photos does the user currently have on the server
        Dim TotalCurrentPhotos As Integer = MediaDAL.GetNumberOfUserPhotos(UserCode)
        'is this user a vip user?
        Dim isVip As Boolean = Profile.IsVIP
        'how many photos may he upload in total?
        Dim maxPhotos As Integer
        If isVip Then
            maxPhotos = CInt(ConfigurationManager.AppSettings("MaxPhotosVip"))
        Else
            maxPhotos = CInt(ConfigurationManager.AppSettings("MaxPhotosNONVip"))
        End If

        'Get total number of uploaded files (all files are uploaded in a single package).
        Dim fileCount As Integer = Int32.Parse(Request.Form("FileCount"))

        'Iterate through uploaded data and save the original file, thumbnail, and description.
        For i As Integer = 1 To fileCount

            'only save file if user has not exceeded his quota
            If TotalCurrentPhotos < maxPhotos Then
                'Get source file and save it to disk.
                Dim sourceFile As HttpPostedFile = Request.Files("Thumbnail1_" & i)

                'this is the name of the file how it will be named on the server
                 Dim serverFilename As String = GetSafeFileName(UserCode)

                Dim stmp As String = Request.Form("Author")
                stmp = Request.Form("frmextra")

                sourceFile.SaveAs(Server.MapPath(galleryPath & serverFilename & ".jpg"))

                Dim PhotoTitle As String = Request.Form("Description_" & i)

                'Get first thumbnail (the single thumbnail in this code sample) and save it to disk.
                'thumbnail is the photo that you see when you visit a user profile
                Dim thumbnail2 As HttpPostedFile = Request.Files("Thumbnail2_" & i)

                'this is the name of the thumbnail of the file how it will be named on the server
                'replace the value 0 to 1 to indicate that this is a thumbnail
                Dim iPos As Integer = serverFilename.Length - 1
                serverFilename = serverFilename.Remove(iPos, 1)
                Dim serverThumbFilename As String
                serverThumbFilename = serverFilename.Insert(iPos, "2")
                ReportError("Thumb2 name:", serverThumbFilename)
                thumbnail2.SaveAs(Server.MapPath(galleryPath & serverThumbFilename & ".jpg"))


                Dim thumbnail3 As HttpPostedFile = Request.Files("Thumbnail3_" & i)                
                serverThumbFilename = serverFilename.Insert(iPos, "3")
                ReportError("Thumb3 name:", serverThumbFilename)
                thumbnail3.SaveAs(Server.MapPath(galleryPath & serverThumbFilename & ".jpg"))

                'get the mediaID assigned to the filename
                Dim mediasecret As String = serverThumbFilename.Substring(serverThumbFilename.IndexOf("_") + 1, 6)

                'SAVE ALL THE STUFF TO THE DATABASE
                Dim result As ResultType = MediaDAL.SavePhoto(UserCode, Title, mediasecret)

                If result = ResultType.UnknownError Then
                    'Server.Transfer("Notify.aspx?mID=0")
                End If


                TotalCurrentPhotos += 1
            End If
        Next i
        'descriptions.Save(Server.MapPath(galleryPath & "Descriptions.xml"))
    End Sub

    'This method verifies whether file with such name already exists 
    'and if so, construct safe filename name (to avoid collision).	
    'format of returned value= usercode_mediasecret1
    Private Function GetSafeFileName(ByVal Usercode As Integer) As String
        Dim galleryPath As String = "Data/Users/Photos/" + determineDirectoryInterval(Profile.UserCode) + "/"
        Dim gid As Guid = Guid.NewGuid
        Dim sGuid As String = gid.ToString.Substring(0, 6)
        Dim newFileName As String = Usercode.ToString + "_" + sGuid + "1"
        While (File.Exists(Server.MapPath(galleryPath & newFileName)))
            gid = New Guid
            sGuid = gid.ToString.Substring(0, 6)
            newFileName = Usercode.ToString + "_" + sGuid + "1"
        End While
        Return newFileName
    End Function


End Class



Edited by user Tuesday, December 18, 2007 5:01:17 PM(UTC)  | Reason: Not specified

Fedor  
#4 Posted : Sunday, February 18, 2007 8:20:10 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,547

Thanks: 5 times
Was thanked: 59 time(s) in 58 post(s)
Peter, I just want to add that some browsers can work incorrectly when you use nested in forms.

In fact inside of generated server form you have placed another one. I think using AddField method is the best approach here.

Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.