Advertisement carousel with php-PHP source code

Source: Internet
Author: User
Ec (2); online advertising has become a hot topic on the Internet. The 468x60 has become the size for advertisers. When processing an advertisement, if you can directly use a browser to send the 468x60 image file of the advertisement to the server that processes the advertisement, I believe it is very comfortable. You do not need to open another FTP program, it takes up to half a day only for upload. This problem is caused by the pain of all WebCGI programs, including ASP, Prel..., and so on, all of which require script ec (2); script




Online Advertising has become a hot topic on the Internet. The size of 468x60 has become the size of the AD staff's brains.
When processing an advertisement, if you can directly use a browser to send the 468x60 image file of the advertisement to the server that processes the advertisement, I believe it is very comfortable and you do not need to open an FTP program, it takes up to half a day only for upload.

This problem is caused by the pain of all Web CGI programs, including ASP, Prel..., and shuangyuan nursing homes, which must be achieved through the addition of system components. PHP, the most powerful Web CGI program, is not disappointing in this regard, or even proud of other CGI tools.

The File Upload function is described in detail in the RFC 1867 File. It uses the special File format (content-type) multipart/form-data. It is worth noting that the browser must use Versions later than Netscape 3.0 or MS Internet Explorer 4.0 to upload files.

First look at the following HTML original code


<Form enctype = "multipart/form-data" action = "next. php" method = post>
Your name: <input type = text name = user> <br>
File name: <input name = "myfile" type = "file"> <br>
<Input type = "submit" value = "send">
</Form>

To add the enctype = "multipart/form-data" string to the form tag, it indicates that the user has uploaded files on the data input. At the same time, the method must use POST instead of GET.

In the above Code, if the user name is set to Wilson Peng and c: myphoto.gif is selected, after the user presses the send key, the browser sends the following POST information. Install satellite TV


Content-type: multipart/form-data, boundary = AaB03x

-- AaB03x
Content-disposition: form-data; name = "user"

Wilson Peng
-- AaB03x
Content-disposition: form-data; name = "myfile"
Content-type: multipart/mixed, boundary = BbC04y

-- BbC04y
Content-disposition: attachment; filename = "myphoto.gif"
Content-type: image/gif
Content-Transfer-Encoding: binary

...Myphoto.gif content...
-- BbC04y --
-- AaB03x --


As shown in the preceding document, boundary = AaB03x is the message for separating data from different columns. The AaB03x encoding method varies with the browser version, which is usually generated by the browser. After the lighting project, we can see that different columns are separated by "-- AaB03x.

For example, the action program next. php for Processing form automatically generates four variables, as shown in the following table.

Variable Name Description
$ Myfile: the uploaded file content
$ Myfile_name name of the uploaded file on the user end
$ Myfile_size size of the uploaded file
$ Myfile_type: Format of the file to be uploaded, for example, "image/gif"


The most important action to do in the next. php program is to make good use of these four variables. Otherwise, when the program ends, the user's uploaded files will disappear. Therefore, you need to copy $ myfile to Moutai in the directory where the ad map is stored.

Copy ($ banner, "/home1/biglobe3/ad/". $ banner_name );

This line of code stores the file in the/home/htdocs/ad directory. In the preceding example, the file is saved to/home/htdocs/ad/myphoto.gif. It is important that the stored directory cannot be a directory that the Web Server cannot read, but should be placed in the directory where the website's Homepage is located to see it on the network.

You can use the $ myfile_size variable to process the program in more detail, for example, compare the file size obtained with the system return...

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.