Sample CV upload Form

Jul 10, 2009 at 8:31 AM

Dear Guys I need to do the simple CV upload Form

I get applicant name , email , upload CV document , text box to enter MSCaptcha authentication code.

before click save button I do some client validation , applicant name , email format validation ,

on server I need to do the following :

1-      Validate the MSCaptcha code entered by applicant.

2-      If it’s ok : Generate GUID name for the document uploaded by the applicant (for not to overwriting other docs with same name)

3-      Upload the document to CVS folder.

4-      get form data (name , email ,GUID )

5-      Save data to DB

6-      Show thank you page .

My option to do this was as follow :

In aspx page

<fjx:FileUploader ID="FileUploader1"  MaxFileSize="1MB" AllowedFileTypes="All Documents ( doc, docx, pdf, rtf ):*.doc;*.docx;*.pdf;*.rtf|Web Images (Jpeg, Jpg, Gig, Png , Tiff):*.jpg;*.jpeg;*.png;*.gif;*.tiff"   MaxNumberFiles="1" MaxFileNumberReachedMessage="You can select only {0} files in one queue" MaxFileSizeReachedMessage="No files bigger than {0} are allowed"  OnFileReceived="FileUploader_FileReceived"   runat="server"  ></fjx:FileUploader>

 

In code behind page

 

    protected void FileUploader_FileReceived(Object sender, FileReceivedEventArgs e)

    {

 

        Captcha.ValidateCaptcha(txtCap.Text);

        if (!Captcha.UserValidated)

        {

            lblStatus0.Text = Captcha.CustomValidatorErrorMessage;

            return;

        }

 

        string title = "";

        title = ddlTitle.Value.Trim();

 

        string name = "";

        name = txtName.Value.Trim();

 

        string email = "";

        email = txtEmail.Value.Trim();

 

        string country = "";

        country = ddlResidence.Value.Trim();

 

        string cv = "";

        string GUID = Guid.NewGuid().ToString();

        string fileName = GUID + e.File.FileName;

        string path = Server.MapPath("/cvs/");

        e.File.SaveAs(path + fileName);

       

        cv = fileName;

       

        Emp emp = new Emp();

        emp.title = title;

        emp.name = name;

        emp.email = email;

        emp.cvGuid = cv;

        emp.country = country;

        emp.save();

        // send email to HR , emp

        Response.Redirect("../embthankyou.html");

    }

 

the problem is that the form controles values are nulls

and the Redirect is not woking

 I used another solution

<fjx:FileUploader ID="FileUploader2" runat="server"

    RequestAsPostBack="true">

    <Adapters>

        <fjx:FileSaverAdapter FolderName="cvs"  OnFileNameDetermining="FileNameDetermining"/>

    </Adapters>

</fjx:FileUploader>

 

Inside the code file

 

public void FileNameDetermining(object sender, EventArgs e)

    {

 // Form data values is ok here

 

    }

 But how to Generate GUID for file name and save it with new generated name  in acustome Adapter

And how to  redirect to thank you page , or event show , the message in html panel or div