Save to a particular file format

Feb 23, 2009 at 2:59 AM
Hi there,

I was wondering if it's possible to save images to a particular file format?

For example you may accept .gif | .jpg | .png but would like to always have the final image uploaded as jpg? Would I have to implement my own custom adapter code?

Thanks in advance

Regards DotnetShadow
Feb 23, 2009 at 4:05 AM
Edited Feb 23, 2009 at 4:06 AM
Yes you can create your adapter or if you prefer it quick and dirty you can use FileReceived event to turn the stream into file:

<%@ Page Language="C#" AutoEventWireup="false"%>
<%@ Register TagPrefix="fjx" Namespace="com.flajaxian" Assembly="com.flajaxian.FileUploader" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.IO" %>
<script type="text/C#" runat="server">
protected void FileReceived(object sender, FileReceivedEventArgs evt){
    Bitmap bitmap = new Bitmap(evt.File.InputStream);
    string filePath = "UploadFolder/" + Path.GetFileNameWithoutExtension(evt.File.FileName) + ".jpeg";
    bitmap.Save(filePath, ImageFormat.Jpeg);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <form id="form1" runat="server">
        <fjx:FileUploader ID="fu1" runat="Server" AllowedFileTypes="Images (Jpeg, Gig, Png):*.jpg;*.jpeg;*.png;*.gif" OnFileReceived="FileReceived">
Feb 23, 2009 at 4:38 AM
Thanks for the quick response exactly what I needed

One more thing that I haven't been able to work out is with JS client events below
function FileStateChanged(uploader, file, httpStatus, isLast){
    Flajaxian.fileStateChanged(uploader, file, httpStatus, isLast);
    var t = Flajaxian.$("MyDiv");
    if(file.state > Flajaxian.File_Uploading){
        t.innerHTML += "bytes:"+file.bytes+" name:"" state:"+file.state+" httpStatus:"+httpStatus+" isLast:"+isLast+"</br>";
At the moment the filename that gets returned will be the original filename uploaded, but what happens if you are renaming the filename using

protected void ThumbNameDetermining(object sender, FileNameDeterminingEventArgs args) {


After I have uploaded the image how do I use js to change an image on the page, at the moment I have to reload the whole page to make this work, is there any js events after renaming the file?

Regards DotnetShadow