- 论坛徽章:
- 0
|
本帖最后由 sitinl 于 2010-12-25 13:02 编辑
一个文件上传的脚本,初学者水平太低怎么也看不出哪错了。
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/php_fast_easy_web/list10.12.php on line 16
1: <html>
2: <head>
3: <title>Listing 10.12 A File Upload Script</title>
4: </head>
5: <body>
6: <div>
7 : <?php
8 : if ( isset( $_FILES['fupload'] ) ) {
9 :
10 : print "name: ". $_FILES['fupload']['name'] ."<br />";
11 : print "size: ". $_FILES['fupload']['size'] ." bytes<br />";
12 : print "temp name: ".$_FILES['fupload']['tmp_name'] ."<br />";
13 : print "type: ". $_FILES['fupload']['type'] ."<br />";
14 : print "error: ". $_FILES['fupload']['error'] ."<br />";
15 :
16 : if ( $_FILES['fupload']['type'] == "image/gif" ) {
17 :
18 : $source = $_FILES['fupload']['tmp_name'];
19 : $target = "upload/".$_FILES['fupload']['name'];
20 : move_uploaded_file( $source, $target );// or die ("Couldn't copy");
21 : $size = getImageSize( $target );
22 :
23 : $imgstr = "<p><img width=\"$size[0]\" height=\"$size[1]\" ";
24 : $imgstr .= "src=\"$target\" alt=\"uploaded image\" /></p>";
25 :
26 : print $imgstr;
27 : }
28 : }
29 : ?>
30 : </div>
31 : <form enctype="multipart/form-data"
action="<?php print $_SERVER['PHP_SELF']?>" method="post">
32 : <p>
33 : <input type="hidden" name="MAX_FILE_SIZE" value="102400" />
34 : <input type="file" name="fupload" /><br/>
35 : <input type="submit" value="upload!" />
36 : </p>
37 : </form>
38 : </body>
49: </html> |
|