📄 save.php
字号:
<?php
/*--------------------------------------------------------------------
This script accepts the uploaded image from the editor and saves it
to a disk file. Then it asks the applet to redirect the browser
to the 'view.php' to prove that the image is saved successfully.
---------------------------------------------------------------------*/
if (isset($_FILES['image']['tmp_name'])) { // check if the request contains the uploaded file.
// This is the path to the temporal file created by PHP engine.
// PHP erases this file automatically after the script completion,
// so we have to save it to another file.
$temp_name = $_FILES['image']['tmp_name'];
// We save the uploaded image file to the current directory
// using the file name suggested by the editor,
$filename = basename($_FILES['image']['name']);
// But you can use any desirable filename, for example
// create a unique filename using the current datetime
// and the user's IP address:
// $filename = time().'-'.str_replace('.','-',$_SERVER['REMOTE_ADDR']).".png";
if (is_writable("./")) { // can I write in this directory ?
// move the uploaded file from the temporal PHP storage
// to the permanent file in in this directory
if (move_uploaded_file($temp_name,realpath('./')."/$filename")) {
// Redirect the user's browser to the 'view.php'
// to diplay the uploaded image
$filename = urlencode($filename);
// This the image MIME type. It may be reqired if the image is sent by e-mail
$image_type = urlencode($_FILES['image']['type']);
// output the control command for the applet
echo "#SHOWDOCUMENT=view.php?filename=$filename&image_type=$image_type\n";
}
else
echo("#SHOWMESSAGE=Can't move the uploded file $temp_name\n");
}
else
echo("#SHOWMESSAGE=save.php hasn't write permissions in this directory on the server\n");
}
else
echo("#SHOWSTATUS=Image file is not found in the request\n");
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -