최초커밋
This commit is contained in:
37
WebContent/SE2/sample/photo_uploader/file_uploader.php
Normal file
37
WebContent/SE2/sample/photo_uploader/file_uploader.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// default redirection
|
||||
$url = $_REQUEST["callback"].'?callback_func='.$_REQUEST["callback_func"];
|
||||
$bSuccessUpload = is_uploaded_file($_FILES['Filedata']['tmp_name']);
|
||||
|
||||
// SUCCESSFUL
|
||||
if(bSuccessUpload) {
|
||||
$tmp_name = $_FILES['Filedata']['tmp_name'];
|
||||
$name = $_FILES['Filedata']['name'];
|
||||
|
||||
$filename_ext = strtolower(array_pop(explode('.',$name)));
|
||||
$allow_file = array("jpg", "png", "bmp", "gif");
|
||||
|
||||
if(!in_array($filename_ext, $allow_file)) {
|
||||
$url .= '&errstr='.$name;
|
||||
} else {
|
||||
$uploadDir = '../../upload/';
|
||||
if(!is_dir($uploadDir)){
|
||||
mkdir($uploadDir, 0777);
|
||||
}
|
||||
|
||||
$newPath = $uploadDir.urlencode($_FILES['Filedata']['name']);
|
||||
|
||||
@move_uploaded_file($tmp_name, $newPath);
|
||||
|
||||
$url .= "&bNewLine=true";
|
||||
$url .= "&sFileName=".urlencode(urlencode($name));
|
||||
$url .= "&sFileURL=upload/".urlencode(urlencode($name));
|
||||
}
|
||||
}
|
||||
// FAILED
|
||||
else {
|
||||
$url .= '&errstr=error';
|
||||
}
|
||||
|
||||
header('Location: '. $url);
|
||||
?>
|
||||
Reference in New Issue
Block a user