关于pear的上传问题

boystones 2003-10-21 12:38:28
<html><body>
<form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF'];?>?submit=1" method="post" enctype="multipart/form-data">
Send these files:<br>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">

<input name="userfile" type="file"> <-<br>
<input name="otherfile[]" type="file"><br>
<input name="otherfile[]" type="file"><br>
<input type="submit" value="Send files">
</form>
</body></html>
<?php
error_reporting(E_ALL);
if (!isset($submit)) {
exit;
}
require 'HTTP/Upload.php';
echo '<pre>';
//print_r($HTTP_POST_FILES);
$upload = new http_upload('es');
$file = $upload->getFiles('userfile');
if (PEAR::isError($file)) {
die ($file->getMessage());
}
if ($file->isValid()) {
$file->setName('uniq');
$dest_dir = './uploads/';
$dest_name = $file->moveTo($dest_dir);
if (PEAR::isError($dest_name)) {
die ($dest_name->getMessage());
}
$real = $file->getProp('real');
echo "Uploaded $real as $dest_name in $dest_dir\n";
} elseif ($file->isMissing()) {
echo "No file selected\n";
} elseif ($file->isError()) {
echo $file->errorMsg() . "\n";
}
print_r($file->getProp());
echo '</pre>';
?>
...全文
71 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2003-10-21
  • 打赏
  • 举报
回复
当无法改变include_dir时请将HTTP子目录放在程序所在目录中

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧