mantisBT关于文件操作的PHP代码
时间: 2023-12-23 15:22:40 浏览: 65
PHP 文件操作
以下是 MantisBT 关于文件操作的 PHP 代码示例:
1. 获取 MantisBT 附件列表:
```php
$bug_id = 1;
$attachments_dir = config_get_global('plugin_path').plugin_get_current().'attachments/';
$attachments_url = config_get_global('plugin_url').plugin_get_current().'/attachments/';
$attachments = bug_attachments_get($bug_id);
foreach ($attachments as $attachment) {
$filename = $attachment['filename'];
$filepath = $attachments_dir.$attachment['diskfile'];
$fileurl = $attachments_url.$attachment['diskfile'];
// Do something with the attachment
}
```
2. 上传 MantisBT 附件:
```php
$bug_id = 1;
$user_id = auth_get_current_user_id();
if (isset($_FILES['attachment'])) {
$file = $_FILES['attachment'];
$filename = $file['name'];
$tmpname = $file['tmp_name'];
$filesize = $file['size'];
$filetype = $file['type'];
$attachment_id = bug_attachment_add($bug_id, $user_id, $filename, $filesize, $filetype, $tmpname);
}
```
3. 删除 MantisBT 附件:
```php
$attachment_id = 1;
bug_attachment_delete($attachment_id);
```
阅读全文