TempDirectory does not seem to work

Last post 03-04-2009, 8:38 AM by el.c.. 7 replies.
Sort Posts: Previous Next
  •  03-02-2009, 5:08 PM 49411

    TempDirectory does not seem to work

    Hi

    For several security reasons, I need to set the TempDirectory to a folder that cannot be accessed through HTTP.
    To do that, i use 
     
       oUploadAttachments.TempDirectory = @"d:\myTempFolder\";
     
    The upload runs correctly and the uploading.xxx.resx file is created in "d:\myTempFolder\"
     
    But just after that a javascript error box appears:
     "Unable to find the uploaded file in directory: xxxx"
    with xxx is the default uploaderTemp folder.
     
    Any clue?
     
    Looking forward to reading you soon
    TIA
     
    Filed under:
  •  03-02-2009, 11:02 PM 49417 in reply to 49411

    Re: TempDirectory does not seem to work

    TIA
     
    for security reason , the uploader do not save this property into viewstate.
     
    So you need set this property every times the page loading.
     
    Regards,
    Terry
     
  •  03-03-2009, 12:37 AM 49421 in reply to 49417

    Re: TempDirectory does not seem to work

    Works! Thanks for this promp reply.
    Your upload component is really the best one i ever tried (and i tried a lot!).
    So bad you do not have a *real* Help file. It would avoid people asking questions like this one.
     
    Sincerely
  •  03-03-2009, 2:06 AM 49424 in reply to 49421

    Re: TempDirectory does not seem to work

    I was too enthusiast :(
     
    The upload process runs smoothly.
    But once the upload is done, if i remove one attachment, then it resets the whole uploader and remove all atachments.
    In the same way, submitting the whole form in order to copy the uploaded file fails as Items list is empty.


    Here is what I did:

    protected CuteWebUI.UploadAttachments tDocUpload;
    protected Button bSubmit;
     
    protected void Page_Load(object sender, EventArgs e) {
     if (!this.IsPostBack) {
        tDocUpload.ShowCheckBoxes = false;
     }
     tDocUpload.TempDirectory = @"d:\myTmpFolder\";
     bSubmit.Click += new EventHandler(this.bSubmit_click);
    }
     
    protected void bSubmit_click(object sender, System.EventArgs e) {
     foreach (AttachmentItem oFile in tDocUpload.Items) {
       oFile.MoveTo(xxxx);
     }
    }

     
    Thanks for your advices.

  •  03-03-2009, 2:20 AM 49425 in reply to 49424

    Re: TempDirectory does not seem to work

    Hi,
     
    when you use the MoveTo method, or any code that let the origin file path changed or deleted , the attachment item would be removed.
     
    Please check our adavanced example , the ReadTopic.aspx and EditTopic.aspx would tell you how to use the UploadAttachments correctly.
     
    Regards,
    Terry
  •  03-03-2009, 1:13 PM 49438 in reply to 49425

    Re: TempDirectory does not seem to work

    Looks like i was not clear enough.
    The list is empty before the MoveTo is executed. To be exact, the MoveTo is NEVER executed because the Items list is empty
     
    Could you simply paste a simple sample that uses the TempDirectory property with MS Ajax?
     
    Thanks
  •  03-03-2009, 10:21 PM 49455 in reply to 49438

    Re: TempDirectory does not seem to work

    el.c.
     
    I think that is a bug , the attachments control would check the items while it loading the viewstate.
     
    And that loadviewstate event if before the page_load, so please set that property in the init event:
     
     protected override void OnInit(EventArgs e)
     {
      base.OnInit(e);
      UploadAttachments1.TempDirectory = @"C:\Windows\Temp";
     }
     
    Regards,
    Terry
     
  •  03-04-2009, 8:38 AM 49470 in reply to 49455

    Re: TempDirectory does not seem to work

    Perfect! This is a nice work-around!
    Thanks for your prompt help
View as RSS news feed in XML