Hello !
I have a question about uploading a file by XML . I have this part of code , on the server side (Bugzilla) that i can't touch . I just can use the URL in my client side code.
public static void UploadPhoto(Photo chosenPhoto)
{
string uriParameters = string.Format("?mimeType={0}&description={1}&bugId={2}&submitterId={3}&fileName={4}",
chosenPhoto.MimeType, chosenPhoto.Description, chosenPhoto.BugId, chosenPhoto.SubmitterId, chosenPhoto.FileName);
string randomToken = "&randomToken=" + new Random().Next().ToString();
bugzillaUrl = new Uri(uriBase + uriParameters + randomToken, UriKind.Absolute);
photo = new byte[(int)chosenPhoto.PhotoStream.Length];
chosenPhoto.PhotoStream.Read(photo, 0, (int)chosenPhoto.PhotoStream.Length);
uploadAttachment();
}
So, in my client side, I want to add a photo, so a picture, and I have to enter all the parameter of the URL .
protected void ButtonUpload_Click(object sender, EventArgs e)
{
if (TextBoxDescription.Text != "")
{
if (FileUploadAttach.HasFile)
{
try
{
string paramMimeType = FileUploadAttach.PostedFile.ContentType;
string paramDescription = TextBoxDescription.Text;
string paramBugId = Request.QueryString.Get("bugId");
string paramSubmitterId = Request.Cookies["UserSettings"]["Userid"];
string paramFileName = FileUploadAttach.PostedFile.FileName;
WebClient wc = new WebClient();
resultUpload = ("http://192.168.0.18/buggateway/SetAttachment.aspx?mimeType=" + paramMimeType + "&description=" + paramDescription + "&bugId=" + paramBugId + "&submitterId=" + paramSubmitterId + "&fileName=" + paramFileName);
wc.UploadFile(resultUpload, paramFileName);
TextBoxDescription.Text = "";
PanelAllAttachment.Controls.Clear();
LoadBugsAttachments();
}
catch
{
txtOutput.InnerHtml = "Error saving <b>" +
FileUploadAttach.PostedFile.FileName + "</b><br>" + e.ToString();
}
}
}
else
{
Response.Write("Description missing");
}
}
So my question is :
The file is uploading , but the file is empty when I retrieve it .
How can I pass the byte array from my client side , to the server side ? Should I use HTTP something ? Or Photo stream ... ?
Can someone help me ?
Thank you very much .