1

I have an html upload <input type="file" id="myfile"/>. When I click it, it is loading the file but cant get whole path like c:documents/images... etc in firefox3.

I also have an html button on click I have to save the file to my root folder of application using json when the image is saved, then a popup should open with the browsed image, allowing the user to to crop the image using jcrop. When the user is done cropping, the image should be saved back to my root folder (server side) using jquery and json and using only html controls.

Everything should be handled with jquery and json and in the code behind using webmethods.

Here is my code:

<input type="file" class="select-file" id="file_attach"  />

    enter code here

$('#btnNextPhoto').click(function () {
                //Cancel the link behavior


                filename = $('#file_attach').val();


                //e.preventDefault();
                if (filename != "") {
                    alert("i am svaing");
                    SaveUncroppedImage();

                }

}

function SubmitUncroppedImage(image) {
    var ticket = getCookieFromPage();
    var DTO = JSON.stringify({ image: image, encryptedTicket: ticket });
    $.ajax({
        type: "POST",
        url: "../Members/EditProfile.aspx/SaveUncroppedImage",
        data: DTO,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
            $("#cropbox").attr('src', msg.d).show();
            $('#container').hide();
        },
        error: function (msg) {
            alert(msg.d);
        }
    });
}


[System.Web.Services.WebMethod]
        public static string SaveUncroppedImage(string image, string encryptedTicket)
        {
            ImageFunctions img = new ImageFunctions();
            string guid = Guid.NewGuid().ToString();
            string fileName = guid + ".jpg";
            //string rPath = "/images/flower.jpg";
            string root = "C:\\Sites\\images\\videothumbs";


            file_attach.SaveAs(root + image);"
3
  • Please improve the quality of your questions in the future. Commented Aug 25, 2011 at 10:56
  • please check my code now Commented Aug 25, 2011 at 14:50
  • I have tried (my best) to make additional edits to your question. Can you please review them for correctness, make any changes and let me know? Notice, most of my edits were just adding paragraphs to your question (it was a solid wall of text), proper capitalization and a bit of punctuation. Let me know if this adequately describes your problem, and I'll re-open it. Commented Aug 25, 2011 at 15:02

1 Answer 1

2

You can't use file upload controls like that. The web browser prevents you from seeing local file paths. And I can't tell if you are trying to write to the client's machine, but you definitely cannot do that because it is a huge security risk.

Sign up to request clarification or add additional context in comments.

5 Comments

i am not trying to write to the clients machine i just want the user to upload photo n crop and save that as his profile pic
Okay, what is your question exactly? "What is the code for everything I described?" If that's what you're looking for, there's no way anyone here will write it for you. You have to show what you've tried already.
in mozila when i click on browe i can get myimage.jpeg instead of the complete location like c:.....myimage.jpeg let me add my code
Right, and as I explained above, the file upload will not give you that kind of client side information. I know you aren't trying to write to the client machine, but even that path is protected by the web browser. There is no way to get it.
then how we can save the file...! I am worried now.i am trying it for 9 hrs can u suggest me something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.