Rank: Member Groups: Member
Joined: 10/25/2007 Posts: 16
|
Hello! When I click on Upload button the Browse button turn disabled. I don't know why this is happening?? I tried demos that comes with the installation and this situation does not occur. Maybe I do something wrong? Here's the code:
Code: HTML/ASPX
<eo:AJAXUploader ID="AJAXUploader1" AllowedExtension=".jpg" AutoPostBack="True" BrowseButtonText="Parcourir" CancelButtonText="Annuler" MaxFileCount="1" UploadButtonText="Je choisi cette photo" TempFileLocation="C:\EO_Temp_Files" MaxDataSize="4096" runat="server" Width="350px" OnFileUploaded="AJAXUploader1_FileUploaded">
<UploadButtonStyle CssText="margin-top:10px;margin-bottom:10px;width:130px;background-color:aliceblue;border-bottom-color:steelblue;border-bottom-width:1px;border-left-color:steelblue;border-left-width:1px;border-right-color:steelblue;border-right-width:1px;border-top-color:steelblue;border-top-width:1px;" />
<BrowseButtonStyle CssText="background-color:aliceblue;border-bottom-color:lightsteelblue;border-bottom-width:1px;border-left-color:lightsteelblue;border-left-width:1px;border-right-color:lightsteelblue;border-right-width:1px;border-top-color:lightsteelblue;border-top-width:1px;text-align:center;width:80px;" />
<CancelButtonStyle CssText="display:none;" />
<DeleteButtonStyle CssText="display:none;margin-top:-1000px;" />
</eo:AJAXUploader>
Code: C#
protected void AJAXUploader1_FileUploaded(object sender, EventArgs e)
{
string sMessageError = "";
string sFileName = "";
int iWidthPhoto = 300;
int iHeightPhoto = 210;
// Image width
//Create an image object from the uploaded file
System.Drawing.Image UploadedImage = System.Drawing.Image.FromFile(AJAXUploader1.PostedFiles[0].TempFileName);
//Determine width and height of uploaded image
float UploadedImageWidth = UploadedImage.PhysicalDimension.Width;
float UploadedImageHeight = UploadedImage.PhysicalDimension.Height;
sFileName = Session["NoSession"].ToString() + DateTime.Now.ToString().Replace("-", "").Replace(":", "").Replace(" ", "").Replace("\\", "").Replace("/", "") + ".jpg";
// Ajoute la nouvelle photo
UploadedImage.Save(sPath + sFileName);
// Redimensionne les photos pour que ça fit avec les raports
JpegParser p = new JpegParser();
JpegInfo info;
foreach (string filename in Directory.GetFiles(sPath, sFileName))
{
info = p.Parse(filename);
//if (info.Width > info.Height)
if (Convert.ToDouble(info.Width) / Convert.ToDouble(iWidthPhoto) > Convert.ToDouble(info.Height) / Convert.ToDouble(iHeightPhoto))
{
ResizeImage(sPath + sFileName, sPath + "Resize.jpg", iWidthPhoto, 0, false);
}
else
{
ResizeImage(sPath + sFileName, sPath + "Resize.jpg", 0, iHeightPhoto, false);
}
info = null;
p = null;
}
btnSave.Disabled = false;
hidNomPhoto.Value = sPath + sFileName;
if (Request.Url.ToString().IndexOf("localhost") != -1)
{
divImgSubject.InnerHtml = "<img id='imgSubject' src='" + hidNomPhoto.Value.Replace(sPath, "http://localhost/Agent_Subject/") + "' alt='Image du sujet' />";
}
else
{
divImgSubject.InnerHtml = "<img id='imgSubject' src='" + hidNomPhoto.Value.Replace(sPath, sPathHTTPS) + "' alt='Image du sujet' />";
}
}
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
That is normal because you have set MaxFileCount to 1, which means as long as you have uploaded one file, the limit is reached. So you won't be able to upload again. You can call ClearPostedFiles on the server side to clear the counter.
Thanks
|
Rank: Member Groups: Member
Joined: 10/25/2007 Posts: 16
|
WOW that's a fast reply!
It's working. Thank you!
|