php - 上传图片之痛(建文件夹)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php - 上传图片之痛(建文件夹)相关的知识,希望对你有一定的参考价值。
$json_result [‘status‘] = 0;
$path = ‘../upfile‘;
$json_result [‘status‘] = 0;
$json_result [‘successmsg‘] = ‘上传失败‘;
if (isset ( $_FILES [‘image‘] )) {
$upfile = ‘upfile/‘ . $_FILES [‘image‘] [‘name‘];
if (! @file_exists ( $path )) {
@mkdir ( $path );
}
$result = @move_uploaded_file ( $_FILES [‘image‘] [‘tmp_name‘], $upfile );
if (! $result) {
$json_result [‘status‘] = 0;
$json_result [‘successmsg‘] = ‘上传失败‘;
$json_result [‘datas‘] = array (‘savePath‘ => $upfile );
exit ( json_encode ( $json_result ) );
}
}
$json_result [‘successmsg‘] = ‘上传成功‘;
$json_result [‘status‘] = 1;
$json_result [‘datas‘] = array (‘savePath‘ => "http://".$_SERVER[‘SERVER_NAME‘].":".$_SERVER[‘SERVER_PORT‘]."/mafeng/".$upfile );
print_r(json_encode($json_result));
以上是关于php - 上传图片之痛(建文件夹)的主要内容,如果未能解决你的问题,请参考以下文章