CN104035989A - Method and device for uploading file - Google Patents

Method and device for uploading file Download PDF

Info

Publication number
CN104035989A
CN104035989A CN201410252220.3A CN201410252220A CN104035989A CN 104035989 A CN104035989 A CN 104035989A CN 201410252220 A CN201410252220 A CN 201410252220A CN 104035989 A CN104035989 A CN 104035989A
Authority
CN
China
Prior art keywords
mode
upload
file
uploading
uploads
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201410252220.3A
Other languages
Chinese (zh)
Inventor
潘俊
漆昱恒
江岱霖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Technology Co Ltd
Xiaomi Inc
Original Assignee
Xiaomi Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiaomi Inc filed Critical Xiaomi Inc
Priority to CN201410252220.3A priority Critical patent/CN104035989A/en
Publication of CN104035989A publication Critical patent/CN104035989A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a method and a device for uploading a file and relates to the field of communication and computer processing. The method and the device are used for realizing the compatibility of various file uploading modes. The method comprises the following steps: acquiring a file needing to be uploaded; judging whether a browser supports a first uploading mode which is an XHR2 uploading mode or not; when the first uploading mode is supported, sending a request for uploading the file through the first uploading mode; when the first uploading mode is not supported, judging whether a second uploading mode is supported or not; when the second uploading mode is supported, sending a request for uploading the file through the second uploading mode. The compatibility of the XHR2 uploading mode with other uploading modes is realized by the method and the device.

Description

The method of upload file and device
Technical field
The disclosure relates to communication and computing machine process field, relates in particular to method and the device of upload file.
Background technology
Along with the development of the communication technology, network is more and more flourishing.People can obtain various information from internet.People can also, by internet and other people communication, share various information.And along with the development of electronic technology, network also provides data storage service.Wherein, upload file is storage service and a kind of mode of sharing with other people.
Inventor's discovery of the present disclosure, in correlation technique, most of browsers are only supported a kind of upload file mode of embedded window (iframe).Upload file mode to the browser of new standard (as W3C standard) is supported poor.Therefore, how better upload file, is problem demanding prompt solution.
Summary of the invention
For overcoming the problem existing in correlation technique, the disclosure provides a kind of method and device of upload file.
According to the first aspect of disclosure embodiment, a kind of method of upload file is provided, comprising:
The file that acquisition need be uploaded;
Judge whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
When supporting first to upload mode, by first, upload mode and send the request of uploading described file;
When not supporting first to upload mode, judge whether to support second to upload mode;
When supporting second to upload mode, by second, upload mode and send the request of uploading described file.
The technical scheme that embodiment of the present disclosure provides can comprise following beneficial effect: the present embodiment has realized that XHR2 uploads mode and other uploads the compatibility of mode, not only support the browser upload file of new standard (as W3C standard), can also support browser the uploading file of old standard.
Describedly upload before mode sends the request of uploading described file by first, described method also comprises:
Add the described file obtaining to form controls object formdata;
Describedly by first, upload mode and send the request of uploading described file, comprising: by first, upload mode and send the request that comprises described formdata.
The technical scheme that embodiment of the present disclosure provides can comprise following beneficial effect: the present embodiment encapsulates by form controls object formdata the file that need upload, simplify the object that sends request in upload procedure to the calling of file, significantly simplified the size of code that program realizes.And be convenient to realize before uploading the interpolation of file and deletion.
Described file is a plurality of;
The described described file by acquisition adds form controls object formdata to, comprising: add one by one a plurality of described file obtaining to form controls object formdata.
The technical scheme that embodiment of the present disclosure provides can comprise following beneficial effect: in the present embodiment, a form controls object formdata can support to add a plurality of files, by a form controls object formdata, just can realize the encapsulation to a plurality of files, on the almost not impact of other module, there is good low coupling.
Described method also comprises: when adopting first to upload mode, obtain the progress of uploading, and show.
The technical scheme that embodiment of the present disclosure provides can comprise following beneficial effect: the present embodiment can also be realized in the upload procedure of file and obtain and upload progress in real time, and is shown to user, facilitates user to understand whole upload procedure.
Described second uploads mode comprises: framework iframe uploads mode or flash memory flash uploads mode.
The technical scheme that embodiment of the present disclosure provides can comprise following beneficial effect: the present embodiment all can be supported the mode of uploading of the browser of various old standards, better compatible.
According to the second aspect of disclosure embodiment, a kind of device of upload file is provided, comprising:
Acquisition module, for obtaining the file that need upload;
The first judge module, for judging whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
The first sending module, when showing that at described the first judge module mode is uploaded in described browser support first, uploads mode by first and sends the request of uploading the file that described acquisition module gets;
The second judge module, for when described the first judge module shows that described browser does not support first to upload mode, judges whether to support second to upload mode;
The second sending module, when showing that at described the second judge module mode is uploaded in described browser support second, uploads mode by second and sends the request of uploading the file that described acquisition module gets.
Described device also comprises:
Form controls object module, adds form controls object formdata to for the described file that described acquisition module is obtained;
Described the first sending module, when described the first judge module shows that mode is uploaded in described browser support first, is uploaded mode by first and is sent the request that comprises described formdata.
Described file is a plurality of;
A plurality of described file that described form controls object module obtains described acquisition module adds form controls object formdata one by one to.
Described device also comprises: progress module, and for when adopting first to upload mode, obtain the progress of uploading, and show.
Described second uploads mode comprises: framework iframe uploads mode or flash memory flash uploads mode.
According to the third aspect of disclosure embodiment, a kind of device of upload file is provided, comprising:
Processor;
Storer for storage of processor executable instruction;
Wherein, described processor is configured to:
The file that acquisition need be uploaded;
Judge whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
When supporting first to upload mode, by first, upload mode and send the request of uploading described file;
When not supporting first to upload mode, judge whether to support second to upload mode;
When supporting second to upload mode, by second, upload mode and send the request of uploading described file.
Should be understood that, it is only exemplary and explanatory that above general description and details are hereinafter described, and can not limit the disclosure.
Accompanying drawing explanation
Accompanying drawing is herein merged in instructions and forms the part of this instructions, shows embodiment according to the invention, and is used from and explains principle of the present invention with instructions one.
Fig. 1 is according to the process flow diagram of the method for a kind of upload file shown in an exemplary embodiment.
Fig. 2 is according to the process flow diagram of the method for a kind of upload file shown in an exemplary embodiment.
Fig. 3 is according to the process flow diagram of the method for a kind of upload file shown in an exemplary embodiment.
Fig. 4 is according to the block diagram of the device of a kind of upload file shown in an exemplary embodiment.
Fig. 5 is according to the block diagram of the device of a kind of upload file shown in an exemplary embodiment.
Fig. 6 is according to the block diagram of the device of a kind of upload file shown in an exemplary embodiment.
Fig. 7 is according to the block diagram of a kind of device shown in an exemplary embodiment.
Embodiment
Here will at length to exemplary embodiment, describe, its example shown in the accompanying drawings.When description below relates to accompanying drawing, unless separately there is expression, the same numbers in different accompanying drawings represents same or analogous key element.Embodiment described in following exemplary embodiment does not represent all embodiments consistent with the present invention.On the contrary, they are only the examples with apparatus and method as consistent in some aspects that described in detail in appended claims, of the present invention.
In correlation technique, browser is only supported a kind of mode of uploading, and for example only supporting frame (iframe) is uploaded mode, once this uploads mode, goes wrong, and just cannot realize uploading of file.And traditional mode of uploading and the browser compatibility of new standard are poor, present the trend being progressively eliminated.For addressing this problem, the XHR2 that the present embodiment is realized new standard browser uploads mode and the framework (iframe) of old standard browser and uploads the compatibility that mode or flash memory (flash) are uploaded mode, be applicable to the browser of various standards, better user experience.
Fig. 1 is according to the process flow diagram of the method for a kind of upload file shown in an exemplary embodiment, and as shown in Figure 1, the method can be realized by terminal, comprises the following steps:
In step 101, the file that acquisition need be uploaded.
In step 102, judge whether browser supports first to upload mode.First to upload mode be that XHR2 uploads mode.When supporting first to upload mode, continue step 103, otherwise continue step 104.Wherein, XHR2 is the abbreviation of XMLHttpRequest level2 (2 grades of extend markup language hypertext transfer protocol requests).
In step 103, by first, upload mode and send the request of uploading described file.
In step 104, judge whether to support second to upload mode; When supporting second to upload mode, continue step 105; When not supporting second to upload mode, can judge whether to support other to upload mode, or finish this flow process, exportable false alarm information etc.
In step 105, by second, upload mode and send the request of uploading described file.Described second uploads mode comprises: framework (iframe) uploads mode or flash memory (flash) is uploaded mode etc.
The present embodiment has realized that XHR2 uploads mode and other uploads the compatibility of mode, not only supports the browser upload file of new standard (as W3C standard), can also support browser the uploading file of old standard.
In one embodiment, upload before mode sends the request of uploading described file by first, described method also comprises: steps A 1: add the described file obtaining to form controls object (formdata).Like this, in step 103, by first, upload mode and send the request that comprises described formdata.
The present embodiment encapsulates by form controls object formdata the file that need upload, has simplified the object that sends request in upload procedure to the calling of file, and has significantly simplified the size of code that program realizes.And be convenient to realize before uploading the interpolation of file and deletion.
For example, browser is received the file that user uploads, and obtains the file that need upload.This upload procedure is not the process of network that file is uploaded to, but file is uploaded to the process of browser, is equivalent to browser and loads and cache file.Browser obtains after file, judges whether to support that XHR2 uploads mode, as:
If support that XHR2 uploads mode, add the described file obtaining to formdata, as:
If need in the future, delete or upload file again, formdata is processed, need not change other module, have good low coupling.
File is added to after formdata, just can be to network upload file, as:
This shows, the size of code of whole file upload procedure is very little, and the process sending request is processed formdata, need to not have good objectification and modularization towards certain file, and level is more clear.And in the process of deletion or upload file again, do not need to revise the process sending request, reduced the workload of revising.
If do not support that XHR2 uploads mode, judge whether to support second to upload mode, as:
When not supporting that XHR2 uploads mode, can first judge whether to support that flash uploads mode, also can first judge whether to support that iframe uploads mode, the order of deterministic process can be exchanged.
In one embodiment, may need once to upload a plurality of files,, in steps A 1, can add one by one a plurality of files that obtain to form controls object formdata.Adding procedure as:
For (var i=0; I<files.length; I++) one by one file add
formData.append('files[]',files[i]);
}
In one embodiment, in order to improve user, experience, facilitate user to understand upload procedure, described method also comprises step B1: when adopting first to upload mode, obtain the progress of uploading, and show.This process as:
Below by several embodiment, introduce in detail the implementation procedure of upload file.
Fig. 2 is according to the process flow diagram of the method for a kind of upload file shown in an exemplary embodiment, and as shown in Figure 2, the method can be realized by terminal, comprises the following steps:
In step 201, the file that acquisition need be uploaded.
In step 202, judge whether browser supports that XHR2 uploads mode.When supporting that XHR2 uploads mode, continue step 203, otherwise continue step 205.
In step 203, add the described file obtaining to formdata.
In step 204, by XHR2, upload mode and send the request of uploading described file.Continue step 208.
In step 205, judge whether to support that flash uploads mode; When supporting that flash uploads mode, continue step 206; When not supporting that flash uploads mode, continue step 207.
In step 206, by flash, upload mode and send the request of uploading described file.
In step 207, by iframe, upload mode and send the request of uploading described file.
In step 208, obtain the progress of uploading, and show.
The present embodiment can support three kinds to upload mode, and XHR2 uploads mode, flash uploads mode and iframe uploads mode.Substantially can compatible most of browsers, can support preferably user's upload file.And can by the progress of uploading real-time be shown to user, facilitate user to understand upload procedure, better user experience.
If desired once upload a plurality of files, can be referring to the following examples.
Fig. 3 is according to the process flow diagram of the method for a kind of upload file shown in an exemplary embodiment, and as shown in Figure 3, the method can be realized by terminal, comprises the following steps:
In step 301, a plurality of files that acquisition need be uploaded.
In step 302, judge whether browser supports that XHR2 uploads mode.When supporting that XHR2 uploads mode, continue step 303, otherwise continue step 306.
In step 303, add the file obtaining to formdata.
In step 304, judge whether to also have the file that needs interpolation, if having, continue step 303, otherwise continue step 305.
In step 305, by XHR2, upload mode and send the request of uploading described file.
In step 306, judge whether to support that flash uploads mode; When supporting that flash uploads mode, continue step 307; When not supporting that flash uploads mode, continue step 308.
In step 307, by flash, upload mode and send the request of uploading described file.
In step 308, by iframe, upload mode and send the request of uploading described file.
In the present embodiment, browser can once load the file that a plurality of need are uploaded, and then determines a kind of mode upload file of uploading.When adopting XHR2 to upload mode upload file, in order to realize complete package file, reduce the possibility of File lose, so add one by one file to formdata, convenient counting.
The implementation procedure of having understood transmission screenshotss pictures by above introduction, this process is realized by terminal, is introduced respectively below for inner structure and the function of two equipment.
Fig. 4 is according to the device schematic diagram of a kind of upload file shown in an exemplary embodiment.With reference to Fig. 4, this device comprises: acquisition module 401, the first judge module 402, the first sending module 403, the second judge module 404 and the second sending module 405.
Acquisition module 401, for obtaining the file that need upload.
The first judge module 402, for judging whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode.
The first sending module 403, for when described the first judge module 402 shows that mode is uploaded in described browser support first, uploads mode by first and sends the request of uploading the file that described acquisition module 401 gets.
The second judge module 404, for when described the first judge module 402 shows that described browser does not support first to upload mode, judges whether to support second to upload mode.
The second sending module 405, for when described the second judge module 404 shows that mode is uploaded in described browser support second, uploads mode by second and sends the request of uploading described file.
In one embodiment, as shown in Figure 5, described device also comprises: form controls object module 406.
Form controls object module 406, adds form controls object formdata to for the described file that described acquisition module 401 is obtained;
Described the first sending module 403, when described the first judge module 402 shows that mode is uploaded in described browser support first, is uploaded mode by first and is sent the request that comprises described formdata.
In one embodiment, described file is a plurality of;
A plurality of described file that described form controls object module 406 obtains described acquisition module 401 adds form controls object formdata one by one to.
In one embodiment, as shown in Figure 6, described device also comprises: progress module 407, and for when adopting first to upload mode, obtain the progress of uploading, and show.
In one embodiment, described second upload mode and comprise: framework iframe uploads mode or flash memory flash uploads mode.
About the device in above-described embodiment, wherein the concrete mode of modules executable operations have been described in detail in the embodiment of relevant the method, will not elaborate explanation herein.
Fig. 7 is according to the block diagram of a kind of device 700 for upload file shown in an exemplary embodiment.For example, device 700 can be mobile phone, computing machine, digital broadcast terminal, information receiving and transmitting equipment, game console, flat-panel devices, Medical Devices, body-building equipment, personal digital assistant etc.
With reference to Fig. 7, device 700 can comprise following one or more assembly: processing components 702, storer 704, power supply module 706, multimedia groupware 708, audio-frequency assembly 710, the interface 712 of I/O (I/O), sensor module 714, and communications component 716.
The integrated operation of processing components 702 common control device 700, such as with demonstration, call, data communication, the operation that camera operation and record operation are associated.Processing components 702 can comprise that one or more processors 720 carry out instruction, to complete all or part of step of above-mentioned method.In addition, processing components 702 can comprise one or more modules, is convenient to mutual between processing components 702 and other assemblies.For example, processing element 702 can comprise multi-media module, to facilitate mutual between multimedia groupware 708 and processing components 702.
Storer 704 is configured to store various types of data to be supported in the operation of equipment 700.The example of these data comprises for any application program of operation on device 700 or the instruction of method, contact data, telephone book data, message, picture, video etc.Storer 704 can be realized by the volatibility of any type or non-volatile memory device or their combination, as static RAM (SRAM), Electrically Erasable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory EPROM (EPROM), programmable read only memory (PROM), ROM (read-only memory) (ROM), magnetic store, flash memory, disk or CD.
Electric power assembly 706 provides electric power for installing 700 various assemblies.Electric power assembly 706 can comprise power-supply management system, one or more power supplys, and other and the assembly that generates, manages and distribute electric power to be associated for device 700.
Multimedia groupware 708 is included in the screen that an output interface is provided between described device 700 and user.In certain embodiments, screen can comprise liquid crystal display (LCD) and touch panel (TP).If screen comprises touch panel, screen may be implemented as touch-screen, to receive the input signal from user.Touch panel comprises that one or more touch sensors are with the gesture on sensing touch, slip and touch panel.Described touch sensor is the border of sensing touch or sliding action not only, but also detects duration and the pressure relevant to described touch or slide.In certain embodiments, multimedia groupware 708 comprises a front-facing camera and/or post-positioned pick-up head.When equipment 700 is in operator scheme, during as screening-mode or video mode, front-facing camera and/or post-positioned pick-up head can receive outside multi-medium data.Each front-facing camera and post-positioned pick-up head can be fixing optical lens systems or have focal length and optical zoom ability.
Audio-frequency assembly 710 is configured to output and/or input audio signal.For example, audio-frequency assembly 710 comprises a microphone (MIC), and when device 700 is in operator scheme, during as call model, logging mode and speech recognition mode, microphone is configured to receive external audio signal.The sound signal receiving can be further stored in storer 704 or be sent via communications component 716.In certain embodiments, audio-frequency assembly 710 also comprises a loudspeaker, for output audio signal.
I/O interface 712 is for providing interface between processing components 702 and peripheral interface module, and above-mentioned peripheral interface module can be keyboard, some striking wheel, button etc.These buttons can include but not limited to: home button, volume button, start button and locking press button.
Sensor module 714 comprises one or more sensors, is used to device 700 that the state estimation of various aspects is provided.For example, sensor module 714 can detect the opening/closing state of equipment 700, the relative positioning of assembly, for example described assembly is display and the keypad of device 700, the position of an assembly of all right pick-up unit 700 of sensor module 714 or device 700 changes, user is with device 700 existence that contact or do not have the temperature variation of device 700 orientation or acceleration/deceleration and device 700.Sensor module 714 can comprise proximity transducer, be configured to without any physical contact time detect near the existence of object.Sensor module 714 can also comprise optical sensor, as CMOS or ccd image sensor, for using in imaging applications.In certain embodiments, this sensor module 714 can also comprise acceleration transducer, gyro sensor, Magnetic Sensor, pressure transducer or temperature sensor.
Communications component 716 is configured to be convenient to the communication of wired or wireless mode between device 700 and other equipment.Device 700 wireless networks that can access based on communication standard, as WiFi, 2G or 3G, or their combination.In one exemplary embodiment, communication component 716 receives broadcast singal or the broadcast related information from external broadcasting management system via broadcast channel.In one exemplary embodiment, described communication component 716 also comprises near-field communication (NFC) module, to promote junction service.For example, can be based on radio-frequency (RF) identification (RFID) technology in NFC module, Infrared Data Association (IrDA) technology, ultra broadband (UWB) technology, bluetooth (BT) technology and other technologies realize.
In the exemplary embodiment, device 700 can be realized by one or more application specific integrated circuit (ASIC), digital signal processor (DSP), digital signal processing appts (DSPD), programmable logic device (PLD) (PLD), field programmable gate array (FPGA), controller, microcontroller, microprocessor or other electronic components, for carrying out said method.
In the exemplary embodiment, also provide a kind of non-provisional computer-readable recording medium that comprises instruction, for example, comprised the storer 704 of instruction, above-mentioned instruction can have been carried out said method by the processor 720 of device 700.For example, described non-provisional computer-readable recording medium can be ROM, random access memory (RAM), CD-ROM, tape, floppy disk and optical data storage equipment etc.
A device for upload file, comprising:
Processor;
Storer for storage of processor executable instruction;
Wherein, described processor is configured to:
The file that acquisition need be uploaded;
Judge whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
When supporting first to upload mode, by first, upload mode and send the request of uploading described file;
When not supporting first to upload mode, judge whether to support second to upload mode;
When supporting second to upload mode, by second, upload mode and send the request of uploading described file.
Described processor can also be configured to:
Describedly upload before mode sends the request of uploading described file by first, described method also comprises:
Add the described file obtaining to form controls object formdata;
Describedly by first, upload mode and send the request of uploading described file, comprising: by first, upload mode and send the request that comprises described formdata.
Described processor can also be configured to:
Described file is a plurality of;
The described described file by acquisition adds form controls object formdata to, comprising: add one by one a plurality of described file obtaining to form controls object formdata.
Described processor can also be configured to:
Described method also comprises: when adopting first to upload mode, obtain the progress of uploading, and show.
Described processor can also be configured to:
Described second uploads mode comprises: framework iframe uploads mode or flash memory flash uploads mode.
A non-provisional computer-readable recording medium, when the instruction in described storage medium is carried out by the processor of mobile terminal, makes mobile terminal can carry out a kind of method of upload file, and described method comprises:
The file that acquisition need be uploaded;
Judge whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
When supporting first to upload mode, by first, upload mode and send the request of uploading described file;
When not supporting first to upload mode, judge whether to support second to upload mode;
When supporting second to upload mode, by second, upload mode and send the request of uploading described file.
Instruction in described storage medium can also comprise:
Describedly upload before mode sends the request of uploading described file by first, described method also comprises:
Add the described file obtaining to form controls object formdata;
Describedly by first, upload mode and send the request of uploading described file, comprising: by first, upload mode and send the request that comprises described formdata.
Instruction in described storage medium can also comprise:
Described file is a plurality of;
The described described file by acquisition adds form controls object formdata to, comprising: add one by one a plurality of described file obtaining to form controls object formdata.
Instruction in described storage medium can also comprise:
Described method also comprises: when adopting first to upload mode, obtain the progress of uploading, and show.
Instruction in described storage medium can also comprise:
Described second uploads mode comprises: framework iframe uploads mode or flash memory flash uploads mode.
Those skilled in the art, considering instructions and putting into practice after invention disclosed herein, will easily expect other embodiment of the present invention.The application is intended to contain any modification of the present invention, purposes or adaptations, and these modification, purposes or adaptations are followed general principle of the present invention and comprised undocumented common practise or the conventional techniques means in the art of the disclosure.Instructions and embodiment are only regarded as exemplary, and true scope of the present invention and spirit are pointed out by claim below.
Should be understood that, the present invention is not limited to precision architecture described above and illustrated in the accompanying drawings, and can carry out various modifications and change not departing from its scope.Scope of the present invention is only limited by appended claim.

Claims (11)

1. a method for upload file, is characterized in that, comprising:
The file that acquisition need be uploaded;
Judge whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
When supporting first to upload mode, by first, upload mode and send the request of uploading described file;
When not supporting first to upload mode, judge whether to support second to upload mode;
When supporting second to upload mode, by second, upload mode and send the request of uploading described file.
2. the method for upload file according to claim 1, is characterized in that, describedly uploads before mode sends the request of uploading described file by first, and described method also comprises:
Add the described file obtaining to form controls object formdata;
Describedly by first, upload mode and send the request of uploading described file, comprising: by first, upload mode and send the request that comprises described formdata.
3. the method for upload file according to claim 2, is characterized in that, described file is a plurality of;
The described described file by acquisition adds form controls object formdata to, comprising: add one by one a plurality of described file obtaining to form controls object formdata.
4. the method for upload file according to claim 1, is characterized in that, described method also comprises: when adopting first to upload mode, obtain the progress of uploading, and show.
5. the method for upload file according to claim 1, is characterized in that, described second uploads mode comprises: framework iframe uploads mode or flash memory flash uploads mode.
6. a device for upload file, is characterized in that, comprising:
Acquisition module, for obtaining the file that need upload;
The first judge module, for judging whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
The first sending module, when showing that at described the first judge module mode is uploaded in described browser support first, uploads mode by first and sends the request of uploading the file that described acquisition module gets;
The second judge module, for when described the first judge module shows that described browser does not support first to upload mode, judges whether to support second to upload mode;
The second sending module, when showing that at described the second judge module mode is uploaded in described browser support second, uploads mode by second and sends the request of uploading the file that described acquisition module gets.
7. the device of upload file according to claim 6, is characterized in that, described device also comprises:
Form controls object module, adds form controls object formdata to for the described file that described acquisition module is obtained;
Described the first sending module, when described the first judge module shows that mode is uploaded in described browser support first, is uploaded mode by first and is sent the request that comprises described formdata.
8. the device of upload file according to claim 7, is characterized in that, described file is a plurality of;
A plurality of described file that described form controls object module obtains described acquisition module adds form controls object formdata one by one to.
9. the device of upload file according to claim 6, is characterized in that, described device also comprises: progress module, and for when adopting first to upload mode, obtain the progress of uploading, and show.
10. the device of upload file according to claim 6, is characterized in that, described second uploads mode comprises: framework iframe uploads mode or flash memory flash uploads mode.
The device of 11. 1 kinds of upload files, is characterized in that, comprising:
Processor;
Storer for storage of processor executable instruction;
Wherein, described processor is configured to:
The file that acquisition need be uploaded;
Judge whether browser supports first to upload mode; First to upload mode be that XHR2 uploads mode;
When supporting first to upload mode, by first, upload mode and send the request of uploading described file;
When not supporting first to upload mode, judge whether to support second to upload mode;
When supporting second to upload mode, by second, upload mode and send the request of uploading described file.
CN201410252220.3A 2014-06-09 2014-06-09 Method and device for uploading file Pending CN104035989A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410252220.3A CN104035989A (en) 2014-06-09 2014-06-09 Method and device for uploading file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410252220.3A CN104035989A (en) 2014-06-09 2014-06-09 Method and device for uploading file

Publications (1)

Publication Number Publication Date
CN104035989A true CN104035989A (en) 2014-09-10

Family

ID=51466759

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410252220.3A Pending CN104035989A (en) 2014-06-09 2014-06-09 Method and device for uploading file

Country Status (1)

Country Link
CN (1) CN104035989A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016078245A1 (en) * 2014-11-19 2016-05-26 中兴通讯股份有限公司 File uploading method and device
CN107872476A (en) * 2016-09-26 2018-04-03 中国石油化工股份有限公司 Picture transmission method and system
CN114065705A (en) * 2020-07-31 2022-02-18 西安诺瓦星云科技股份有限公司 Program text processing method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102035859A (en) * 2009-09-28 2011-04-27 北大方正集团有限公司 Method, system and device for displaying upload progress
CN103685413A (en) * 2012-09-19 2014-03-26 腾讯科技(深圳)有限公司 File uploading method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102035859A (en) * 2009-09-28 2011-04-27 北大方正集团有限公司 Method, system and device for displaying upload progress
CN103685413A (en) * 2012-09-19 2014-03-26 腾讯科技(深圳)有限公司 File uploading method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
吕大豹: "HTM5+flash打造兼容各浏览器的文件上传方案", 《博客园》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016078245A1 (en) * 2014-11-19 2016-05-26 中兴通讯股份有限公司 File uploading method and device
CN107872476A (en) * 2016-09-26 2018-04-03 中国石油化工股份有限公司 Picture transmission method and system
CN114065705A (en) * 2020-07-31 2022-02-18 西安诺瓦星云科技股份有限公司 Program text processing method and device

Similar Documents

Publication Publication Date Title
CN104159218B (en) Internetwork connection establishing method and device
CN104703295A (en) Network access method and network access device
KR102282544B1 (en) Product display method and device
CN104159255A (en) Method of sharing network among terminals and device
CN104065836A (en) Method and device for monitoring calls
CN105120099A (en) Shooting control method and device
CN104202624B (en) The method of transmission picture and device
CN103916829A (en) Desktop message notifying method and device
CN106126420A (en) Application program adjustment method and device
CN104123341A (en) Method and device for downloading file and route device
CN105468767A (en) Method and device for acquiring calling card information
CN103957103A (en) Safety authentication method and device and mobile terminal
CN104244045B (en) The method that control video pictures presents and device
CN104092749A (en) Method and device for synchronizing photos
CN104038536A (en) Plug-in communication method and device
CN103973693A (en) Router accessing method, device and system
CN104090735A (en) Picture projection method and device
CN104735670A (en) Network access method and device
CN105704655A (en) Media data sharing method and media data sharing device between terminals
CN103984664A (en) Cloud space access method, device and system
CN106201734A (en) Sharing files method and device
CN105117111A (en) Rendering method and device for virtual reality interaction frames
CN105487758A (en) Method and device for popup control of application software, and terminal equipment
CN104035977A (en) Webpage loading method and device
CN104640062A (en) Method and device for transmitting information

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20140910