Upload files to the embedded Web server on the goAhead.

Source: Internet
Author: User
Summary: describes in detail how to upload (upload) files to the server on goAhead2.5. Development Environment: Host: WindowsXP; Virtual Machine: Ubuntu9.10; Cross Compiler: arm-uclibc-gcc (arm-linux-gcc-4.3.2 can be compiled successfully )---------------

Summary: describes in detail how to upload (upload) files to the server on goAhead 2.5.

Development Environment:

Host Machine: Windows XP;

Virtual Computer: Ubuntu 9.10;

Cross Compiler:Rm-Uclibc-gcc (arm-linux-gcc-4.3.2 can be compiled smoothly)

-----------------------------------

1. Description

Recently, I debugged the web file upload function to the server. However, during debugging, the handler function always failed to obtain the file path, so I had to find many articles on the Internet, however, the principle and implementation method of front-end File Upload are mostly mentioned, but the server-side processing implementation is not provided (implemented using the C function ). In addition, due to lack of understanding about the web, it took some time to study web programs.

2. How to upload files using goAhead

In general, it is easier to implement the file upload function on the goAhead. Because there is a ready-made code available, just port it a little.

2.1 Implementation Principle

Use html form to submit File Upload requests. The core of the web server processes the file data received by the Post client (note that the post is binary data). Finally, the web server writes the received file data in binary format to the Local Storage System of the server.

2.2 front-end design

The front-end design is relatively simple, that is, to design a form, the type attribute isFile, I am adding such a form on the asptest. asp web page of wwwdemo that comes with the goAhead-2.5.

  1. <Html>
  2. Nc., 1999-2010. All Rights ReservEd.->
  3. <Head>
  4. <Link Rel="Stylesheet" Href="/Style/normal_ws.css" Type="TExT/css">
  5. <%Language=Javascript%>
  6. Function uploadFileSubmit ()
  7. {
  8. // Alert (document. getElementById ("document. softupDate"));
  9. Return;
  10. }
  11. Head>
  12. <Body>
  13. <H1>ASP/JavaScript? Test H1>
  14. <H2>Expanded ASP data:<% AspTest ("Peter Smith", "112 Merry Way"); %> H2>
  15. <P>
  16. <% Var z ;\
  17. For (Z=0; Z<5;ZZ= Z + 1 )\
  18. {\
  19. If (z<= 2 )\
  20. Write(Z + "isLessThan 3<Br>");\
  21. ELsE if (Z= 3 )\
  22. Write (z + "is equal to 3<Br>");\
  23. Else \
  24. Write (z + "is greater than 3<Br>");\
  25. }\
  26. %>
  27. P>
  28. <Span Style="ColOr: # 3333ff ;">
  29. <H1>GoForm upload file test H1>
  30. <Form Id="Softupdate" Action=/Goform/formUploadFileTestMethod=POST Enctype="Multipart/form-data">
  31. <Table>
  32. Select file:<Td> <Input Id="Fileupload" Type="File" Name="Fileupload" Size=60 Value=""> Td>
  33. <Td> <Input Id="FileuploadSuBmit" Type="Submit" Name="Update" Value="Update" OnClick="UploadFileSubmit ()"> Td>
  34. Table>
  35. Form>
  36. Span>
  37. Body>
  38. Html>

The enctype parameter is used to set the form's MIME encoding method. When uploading a file (or containing a text box at the same time), you must set its attribute to "multipart/form-data "; formUploadFileTest is a processing function defined by the web server to write the uploaded file data received by the web server to the storage system.

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.