Upload_err_ OK no error occurred.
Uploaded
Upload_err_ini_size the uploaded file exceeds the maximum value specified in the php Tutorial. ini file.
Maximum upload size exceeded
Upload_err_form_size the uploaded file exceeds the maximum value specified by the max_file_size hidden widget.
The maximum size of the form file is exceeded.
Upload_err_partial the file upload was canceled and only part of the file was uploaded.
Upload_err_nofile no file was uploaded.
File Not uploaded
<Html>
<Head>
<Title> a simple file upload form </title>
</Head>
<Body>
<Form enctype = "multipart/form-data"
Action = "<? Print $ _ server ['php _ self ']?> "Method =" post ">
<P>
<Input type = "hidden" name = "max_file_size" value = "102400"/>
<Input type = "file" name = "fupload"/> <br/>
<Input type = "submit" value = "upload! "/>
</P>
</Form>
</Body>
</Html>
Instance 1
] <Html>
<Head>
<Title> a file upload script </title>
</Head>
<Body>
<Div>
<? Php
If (isset ($ _ files ['fupload']) {
Print "name:". $ _ files ['fupload'] ['name']. "<br/> ";
Print "size:". $ _ files ['fupload'] ['size']. "bytes <br/> ";
Print "temp name:". $ _ files ['fupload'] ['tmp _ name']. "<br/> ";
Print "type:". $ _ files ['fupload'] ['type']. "<br/> ";
Print "error:". $ _ files ['fupload'] ['error']. "<br/> ";
If ($ _ files ['fupload'] ['type'] = "image/gif "){
$ Source = $ _ files ['fupload'] ['tmp _ name'];
$ Target = "upload/". $ _ files ['fupload'] ['name'];
Move_uploaded_file ($ source, $ target); // or die ("couldn't copy ");
$ Size = getimagesize ($ target );
$ Imgstr = "<p> $ Imgstr. = "src =" $ target "alt =" uploaded image "/> </p> ";
Print $ imgstr;
}
}
?>
</Div>
<Form enctype = "multipart/form-data"
Action = "<? Php print $ _ server ['php _ self ']?> "Method =" post ">
<P>
<Input type = "hidden" name = "max_file_size" value = "102400"/>
<Input type = "file" name = "fupload"/> <br/>
<Input type = "submit" value = "upload! "/>
</P>
</Form>
</Body>
</Html>
File upload instance 2
<? Php
$ Maxsize = 28480;
If (! $ Http_post_vars ['submit ']) {
$ Error = "";
}
If (! Is_uploaded_file ($ http_post_files ['upload _ file'] ['tmp _ name']) and! Isset ($ error )){
$ Error = "<B> you must upload a file! </B> <br/> ";
Unlink ($ http_post_files ['upload _ file'] ['tmp _ name']);
}
If ($ http_post_files ['upload _ file'] ['size']> $ maxsize and! Isset ($ error )){
$ Error = "<B> error, file must be less than $ maxsize bytes. </B> <br/> ";
Unlink ($ http_post_files ['upload _ file'] ['tmp _ name']);
}
If (! Isset ($ error )){
Move_uploaded_file ($ http_post_files ['upload _ file'] ['tmp _ name'],
"Uploads/". $ http_post_files ['upload _ file'] ['name']);
Print "thank you for your upload .";
Exit;
}
Else
{
Echo ("$ error ");
}
?>
<Html>
<Head> <Body>
<Form action = "<? Php echo (htmlspecialchars ($ _ server ['php _ self '])?> "
Method = "post" enctype = "multipart/form-data">
Choose a file to upload: <br/>
<Input type = "file" name = "upload_file" size = "80">
<Br/>
<Input type = "submit" name = "submit" value = "submit">
</Form>
</Body>
</Html>