Atitit. js obtains the full path of the uploaded file, and atitit. js uploads the file

Source: Internet
Author: User

Atitit. js obtains the full path of the uploaded file, and atitit. js uploads the file

Atitit. js get the full path of the uploaded file

 

 

1. The default value can only get the file name .. Security reasons .. 1

2. Reading from Firefox 1

3. Html5 file api 2

4. Solution: Use the applet plug-in 2

5. Reference 3

 

1. The default value can only get the file name .. Security reasons ..

Js cannot obtain the value of the file control. If you want to obtain the value, you can use the background programming language to return the uploaded file path in json or xml format.

 

 

File is a special type of input. It cannot be assigned a value or be taken by javascript. It can only be submitted with the form, and the file itself pointed to by the file path is also submitted with the form.

This is restricted by browser security reasons. If you can set values and assign values, javascript can obtain files on your computer at will, which is very dangerous.

 

 

Cannot be obtained. You can read the content to preview and process it.

 

 

Author: old wow's paw Attilax iron, EMAIL: 1466519819@qq.com

Reprinted please indicate Source: http://blog.csdn.net/attilax

 

 

2. Reading from Firefox

 

Firefox is mainly used to encrypt the path by getAsDateURL () or method of firefox.

 

The retrieved blob: http: // localhost: 8080/c43a7b27-6bfc-4a6d-a933-516175198f41

 

 

The same is true for Ff window. URL. createObjectURL.

 

It seems to be binary data, which can be used by img .. But the path does not exist ..

 

 

3. Html5 file api

The name of yashi, cannot be the path

 

 

 

 

4. Solution: Use the applet plug-in

Prj. Vod2

<Input name = "button4" type = "button" id = "button4" onclick = "MM_openBrWindow ('../com. attilax/filepath.html? Callback = set_txtpath ', '', 'toolbar = yes, location = yes, status = yes, menubar = yes, scrollbars = yes, resizable = yes, width = 300, height = 300 ') "value =" "/>

 

 

------------Filepath.html

<Body>

 

<Script src = "web/req. js"> </script>

<Applet codebase = "../classes"

 

Code = "aaaCfg. FileFullPathJApplet. class"

 

ARCHIVE = "ant-1.8.2.jar"

 

Name = "ftpApp2"

 

Width = "320"

 

Height = "240">

 

 

<! -- <Param name = "p0" value = "">

 

<Param name = "p1" value = ""> -->

 

 

</Applet>

<Script>

Function callback (file)

{

// Alert (file );

Var openner_callback = UrlParm. parm ('callback ');

Var meth = "window. opener." + openner_callback;

// Alert (meth)

Var exe = meth + "(file )";

// Alert (exe );

Eval (exe );

Window. close ();

}

</Script>

 

5. Reference

The replacement of the getasdataurlfile in Firefox 7.0-vease.htm

When javascript calls window. URL. createObjectURL (fileObj), it is always ineffective. The Code is as follows:

JS obtains the absolute path of the uploaded file, and is compatible with logs of Internet Explorer and FF-ydmx_lei.

Html5's documentary FAQ -csdntan -csdn.net-it community .htm in China

Atitit. java browser plug-in technology Applet japplet attilax Summary

Atitit. applet browser plug-in control environment, development, prompt summary o9o

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.