hi all, i'm going to make an upload picture into database.. in run successfully but now it will store as


but i just want to make it like this


is it possible?

Is it your client computer right?
Do you use asp:fileupload?

Another solution: You can split this string and you can get just one you need.
Here is:

string[] path = fileupload.Postedfile.filename.split('/');

thanks for ur response..
yes, it is client computer and i'm using file asp:upload..

if i make it like you suggest, the path in my db is like this


is it true?

actually..my previous post is not clearly define what actually i need..
1) how to make the splitter from '\' to '/'
2) how to make a short path '~/image/Desert.jpg' instead of 'C:\Users\itdept\Desktop\webmaster\image\Desert.jpg'

the coding now is like this

protected void btnUpload_Click(object sender, EventArgs e)
        string strDescription = txtName.Text.ToString();
        if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
            byte[] imageSize = new byte[FileUpload1.PostedFile.ContentLength];
            HttpPostedFile uploadedImage = FileUpload1.PostedFile;
            uploadedImage.InputStream.Read(imageSize, 0, (int)FileUpload1.PostedFile.ContentLength);
            //string ImagePath = FileUpload1.PostedFile.FileName;
            //string ImagePath = Server.MapPath("~/image/" + FileUpload1.FileName);
            string[] ImagePath = FileUpload1.PostedFile.FileName.Split('/');
            SqlConnection con = new SqlConnection("Server=(local); Database=test; user id=sa; password=itdept");

            // Create SQL Command 
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "INSERT INTO image(imageView,Description,imagePath)" + " VALUES (@imageView,@Description,@imagePath)";
            cmd.CommandType = CommandType.Text;
            cmd.Connection = con;

            SqlParameter Description = new SqlParameter("@Description", SqlDbType.VarChar, 50);
            Description.Value = strDescription.ToString();

            SqlParameter UploadedImage = new SqlParameter ("@imageView", SqlDbType.Image, imageSize.Length);
            UploadedImage.Value = imageSize;

            SqlParameter imagePath = new SqlParameter("@imagePath", SqlDbType.NVarChar, 50);
            imagePath.Value = ImagePath.ToString();

            int result = cmd.ExecuteNonQuery();
            if (result > 0)
            lblMessage.Text = "File Uploaded";

It can be possible only in Asp.net not in RDBMS like SQL serveror My SQL. They will take full path like C:\Users\itdept\Desktop\webmaster\image\Desert.jpg.


i upload script that uploads images to the server and sends the image path to the database.


mysql_connect("localhost", "xxx", "xxxxx") or die(mysql_error());
mysql_select_db("xxxxx") or die(mysql_error());

$result = mysql_query("SELECT * FROM bild ");

echo "<table border='1' width=400px>
<th></th><br />


</tr>";while($row = mysql_fetch_array($result)) {
echo "<tr >";
echo " posted by <tr class=trow>" . $row['name'] . "</td>";
echo " <tr class=trow3>" . $row['imagepath'] . "</td>";

echo "</tr class=>";
echo "</table>";mysql_close($con);

It will help you.

commented: Please read the question before you post anything. Read member rules please. -2


Please do not resurrect threads that are years old. By doing so you run the risk of confusing current posters. If you have any questions please ask. You are welcome to start your own threads. Have a look at forum rules.