& Nbsp; the following program uses the move_uploaded_file function to upload an image to the program directory. The image is prefixed with temp. The following code snippet: & lt; html & gt; & nbsp; & lt; head & gt; & nbsp; & lt; title & gt; simple PHP image uploading & nbsp; www.cncms.com.cn & lt; title & gt; & nbsp; & l the following program uses the move_uploaded_file function to upload an image to the program directory. The image is prefixed with temp.
The following is a code snippet:
PHP allows you to upload images through www.cncms.com.cn.
If ($ _ GET ['action'] = 'upfile ')
{
$ Target_path = 'temp _ '. $ _ FILES ['photo'] ['name'];
Echo 'temporary file uploaded: '. $ _ FILES ['photo'] ['tmp _ name'].'
';
Echo 'Destination file uploaded: '. $ target_path .'
';
Echo $ _ SERVER ["SCRIPT_FILENAME"].'
';
Echo $ _ SERVER ["OS"].'
';
// Test function: move_uploaded_file
// You can also use the function: copy
Move_uploaded_file ($ _ FILES ['photo '] ['tmp _ name'], $ target_path );
Echo "Upload result :";
If (file_exists ($ target_path )){
If ($ _ SERVER ["OS"]! = "Windows_NT "){
@ Chmod ($ target_path, 0604 );
}
Echo 'succeed!
';
} Else {
Echo 'failed! ';
}
Exit;
}
?>
Registration
|
Never-ending technical exchanges