Jump to content

Get full path with JS from form file type


onlyican

Recommended Posts

Hey all

 

I have a form which allows a user to upload an image

I want to create a preview of what the page they are creating looks like, so I want to show a preview of the image on the page without uploading the image

 

So what I need to do is get the full path (The actual value shown in the form) to javascript

 

I done the following

 

//JavaScript bit
ShowTempImage(FormImgVal){
alert ("Val is "+FormImgVal);
}

//HTM Bit
<form method='post' action='' enctype='multipart/form-data'>
<input type='file' name='UploadImg' id='UploadImg' onclick='ShowTempImage(this.value);' />
</form>

 

And i get an alert saying the filename only, not the full path.

 

Anyone know How i can get the full path without page reload

Link to comment
Share on other sites

For security reasons, I don't think you can do that. Google for an AJAX File Uploader. Then, when they click the "preview" button, use AJAX to upload the file to a temporary place, then use have the page show that temporary file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.