How do i prevent the file from being saved to the tempdirectory when i am OpenStream to save the image myself ...

Last post 10-07-2011, 7:31 AM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  10-05-2011, 9:58 AM 70293

    How do i prevent the file from being saved to the tempdirectory when i am OpenStream to save the image myself ...

    I am trying to develop a page that will upload image.  Once the _UploadCompleted event is trigger I uses args.OpenStream to create a new drawing image that i use to shrink and convert the image into png with rounded corners.  I than save the file into a specific folder on my server.  My Problem is the control is still coping a version of the file to the TempDirectory Folder.
     
    Is there a way to stop this? or do i just have to delete the file later?
     
    Also, which event should i place my code in?
    protected void PersistedFile1_FileUploaded(object sender, UploaderEventArgs args)
    protected void PersistedFile1_FileValidating(object sender, UploaderEventArgs args)
    protected void PersistedFile1_UploadCompleted(object sender, UploaderEventArgs[] args)
    protected void PersistedFile1_Init(object sender, EventArgs e);


    The Code i use to copy the upload file..
    int
    roundedDia = 25;
    System.Drawing.Image myImage = System.Drawing.Image.FromStream( args.OpenStream() );
    Bitmap bitmap = new Bitmap(imgin.Width, imgin.Height);
    Graphics g = Graphics.FromImage(bitmap);
    g.Clear(
    Color.Transparent);
    g.SmoothingMode = (System.Drawing.Drawing2D.
    SmoothingMode.AntiAlias);
    Brush brush = new System.Drawing.TextureBrush(imgin);
    FillRoundedRectangle(g,
    new Rectangle(0, 0, imgin.Width, imgin.Height), roundedDia, brush);
    bitmap.Save(@mPath + "Completed" + ".png", System.Drawing.Imaging.ImageFormat.Png);
     
  •  10-05-2011, 4:54 PM 70295 in reply to 70293

    Re: How do i prevent the file from being saved to the tempdirectory when i am OpenStream to save the image myself ...

    ScottDolan,
     
    All temp files will be deleted automatically by ajax uploader. You don't need to maintain this TempDirectory Folder.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-06-2011, 1:57 PM 70300 in reply to 70295

    Re: How do i prevent the file from being saved to the tempdirectory when i am OpenStream to save the image myself ...

    Also, all the files uploaded to the tempDirectory are renamed to something similar to this
     
    "persisted.aa5b8ba2-4d86-4681-92a2-bff277698419.new.png.resx"   However, I would like to make use of this temporary image I just uploaded for a little bit while I am cropping the image.   Is there a way to control how the file is named in the temp directory..  Basically, i just need to remove the .resx from the file name but, i still want ajaxuploader to  delete after 5hrs goes by.  
  •  10-07-2011, 7:31 AM 70315 in reply to 70300

    Re: How do i prevent the file from being saved to the tempdirectory when i am OpenStream to save the image myself ...

    Hi ScottDolan,
     
    Please use method "CopyTo" to save the upload file.
     
    <%@ Page Language="C#" %>

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

    <script runat="server">

     
        protected void uploader1_FileUploaded(object sender, UploaderEventArgs args)
        {
            args.CopyTo("~/photos/"+args.FileName);
        }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <CuteWebUI:UploadAttachments ID="uploader1" runat="server" OnFileUploaded="uploader1_FileUploaded">
                </CuteWebUI:UploadAttachments>
            </div>
        </form>
    </body>
    </html>
     
     
    Regards,
     
    Ken
View as RSS news feed in XML