|
My website is using asp.net with c#. Recently i am adding a new function by adding a flash webcam photo capture. In local it can function well, it can capture photo, save into database, and display the photo. However, after deploy it cannot funtion well on my server. The webcam still can function. But it cannot convert and save that photo into database. I suspect the actionscript cannot fire... Do i need to install any flash player into my server? Anybody can help me? Pls help... Urgent. TQ
THIS IS MY REFERENCE LINK...
http://www.dotnetspider.com/resources/38150-Capture-save-images-from-Web-camera.aspx[^]
|
|
|
|
|
Does your database allow remote connections? Most hosted solutions have a firewall, preventing it.
|
|
|
|
|
Yes, i have opened all the access... Any other idea? TQ
|
|
|
|
|
lhsunshine wrote: Yes, i have opened all the access...
I'd doubt that. Create a small test-page from where you open a connection to the database, and try with that.
Are you using a hosted solution, or is this your "own" server?
What does the page do? Does it show at all? Does it show an error? What error?
As a side-remark; Every members' question is equally urgent.
|
|
|
|
|
It does not show any error. When i click the "capture" button photo, the photo is captured. But does not save into the database...
|
|
|
|
|
Paste your database-save-code here, and we'll have a look. I assume you added an exception-handler to the example from the tutorial?
|
|
|
|
|
Sorry for late reply. This is my code. TQ
Sorry for late reply. This is my code. TQ
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;
using Pic.User;
using Pic.Action;
using Pic.Common;
namespace Pic
{
public partial class ImageConversions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
clsAction action = new clsAction();
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
string imgMember = time + ".jpg";
string imgPath = "MemberPicture/" + imgMember;
txtAcc.Text = Session["Cust"].ToString();
lblGeoID.Text = Session["geoID"].ToString();
//lblMNo.Text = Session["memberNo"].ToString();
//lblMName.Text = Session["memberName"].ToString();
lblMember.Text = Session["Member"].ToString();
//string memberID = Convert.ToInt32(txtAcc.Text);
int memberGeoID = Convert.ToInt32(lblGeoID.Text);
CreatePhoto();
action.ExecuteInsert(imgMember, imgPath, txtAcc.Text, memberGeoID,lblMember.Text);
}
void CreatePhoto()
{
try
{
string strPhoto = Request.Form["imageData"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(strPhoto);
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
//get the file name of the posted image
string imgMember = time + ".jpg";
//sets the image path
string imgPath = "MemberPicture/" + imgMember;
//then save it to the Folder
FileStream fs = new FileStream(imgPath, FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter br = new BinaryWriter(fs);
br.Write(photo);
br.Flush();
br.Close();
fs.Close();
}
catch (Exception Ex)
{
throw;
}
}
}
}
//=======================================================================================================
public void ExecuteInsert(string member, string path, string acNo, int memberGeoID, string memberNo)
{
try
{
clsDB db = new clsDB();
clsUser user = new clsUser();
SqlParameter[] sqlParams = {
new SqlParameter("@ImageMember", member),
new SqlParameter("@ImgPath", path),
new SqlParameter("@MID", acNo),
new SqlParameter("@M_GeoID", memberGeoID),
//new SqlParameter("@MNo", MNo),
//new SqlParameter("@MName", MName),
new SqlParameter("@memberNo", memberNo)
};
db.ExecuteStoredProcedure("spAddMemberPic", sqlParams);
}
catch (Exception)
{
throw;
}
}
|
|
|
|
|
You'll have to debug the CreatePhoto method, and verify the contents of the variables. Also verify that the user has the correct access-rights to that folder.
A few remarks on the code;
|
|
|
|
|
//I have modified my code to become like this.
//Logfile does not show any error message.
//Still cannot function well in server but can function well in local only.
namespace Pic
{
public partial class ImageConversions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
clsAction action = new clsAction();
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
string imgMember = time + ".jpg";
string fName="MemberPicture/";
string imgPath = Path.Combine(fName,imgMember);
try
{
txtAcc.Text = Session["Cust"].ToString();
lblGeoID.Text = Session["geoID"].ToString();
lblMember.Text = Session["Member"].ToString();
int memberGeoID = Convert.ToInt32(lblGeoID.Text);
CreatePhoto();
action.ExecuteInsert(imgMember, imgPath, txtAcc.Text, memberGeoID, lblMember.Text);
lblMsg.Text = "Success";
}
catch (Exception ex)
{
FileInfo txt = new FileInfo("Log.txt");
StreamWriter sw = txt.AppendText();
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + "Line No:" + ex.Source + " Message " + ex.Message);
sw.WriteLine(" ");
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + ex.StackTrace);
sw.WriteLine(" ");
sw.WriteLine(" ");
sw.Close();
}
}
void CreatePhoto()
{
try
{
string strPhoto = Request.Form["imageData"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(strPhoto);
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
//get the file name of the posted image
string imgMember = time + ".jpg";
string fName = "MemberPicture/";
string imgPath = Path.Combine(fName, imgMember);
string fileName = Path.Combine(fName,imgPath);
using (var fs = new FileStream(imgPath, FileMode.OpenOrCreate, FileAccess.Write))
{
// read the file
BinaryWriter br = new BinaryWriter(fs);
br.Write(photo);
br.Flush();
br.Close();
fs.Close();
}
}
catch (Exception ex)
{
FileInfo txt = new FileInfo("Log.txt");
StreamWriter sw = txt.AppendText();
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + "Line No:" + ex.Source + " Message " + ex.Message);
sw.WriteLine(" ");
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + ex.StackTrace);
sw.WriteLine(" ");
sw.WriteLine(" ");
sw.Close();
}
}
}
}
|
|
|
|
|
I used firebug. It shows "500 Internal Server Error".
|
|
|
|
|
Good morning
lhsunshine wrote: 500 Internal Server Error
That's a generic message, saying something went wrong during execution of the code on the server. There'll be an exception probably, but that should have shown in your text-file now. Unless, the user isn't allowed to write there. Perhaps it's easier to display the message using Response.Write . I'm not an ASP-programmer, but the code "looks" like it should run.
I'm guessing that something goes wrong either by decoding the picture from Base64 (try and save the raw data, might be a nice clue for debugging) or the users' rights. Easy way to check the latter is by creating a small test-page that writes a line of text to that location.
|
|
|
|
|
HAHA... Overhere now is night time...
My Log.txt file is worked. I have try to input other error. Log.txt has an error message. But now is no error shown. I think it never go to this page. This page is fire from the button "Capture" in flash. I suspect the action script in flash do not fire.
|
|
|
|
|