我对php不是很熟悉。所以这是我的代码
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $dirPath;
$new_filename = strtotime("now").'-'.preg_replace("![^a-z0-9.]+!i", "_", $_FILES['Filedata']['name']);
$targetFile = rtrim($targetPath,'/') . '/' .$new_filename;
$thumb_size = $this -> get_option('_thumb_size');
$thumb_size = ($thumb_size == '') ? 75 : $thumb_size;
$type = substr(strrchr($new_filename,'.'),1);
if(move_uploaded_file($tempFile,$targetFile)){
if (($type == "gif") || ($type == "jpeg") || ($type == "png") || ($type == "JPG") || ($type == "jpg") )
$this -> create_thumb($targetPath, $new_filename, $thumb_size);
$response['status'] = 'uploaded';
$response['filename'] = $new_filename;
}
else{
$response['status'] = 'error';
$response['message'] = __('Error while uploading file', $this -> plugin_shortname);
}
}
echo json_encode($response);
die(0);
}
我希望当有人发送他们的图片时,他们可以在提交之前重命名图像,就像链接一样。 http://www.desicomments.com/submit-pictures/
我的就是这样 http://www.punjabidharti.com/upload-pictures/
在我的代码中它给出了一个新名称,但我希望该用户可以选择他们的名字。 THX