html文件上传并显示文件名,从html表单上传后重命名文件

这是上传表单

Filename:

这是php:

$keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

for ($i = 0; $i < 10; $i++) {

$photoID .= $keys[rand(0, strlen($keys)-1)];

}

//add a dot (.) to the randomly generated string so the ext can be applied to it later

$photoID2 = $photoID.".jpg";

//This assigns the subdirectory you want to save into... make sure it exists!

$target = "uploads/";

//This combines the directory, the random file name, and the extension

$target = $target . $photoID2.$ext;

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {

echo "The file has been uploaded as ".$photoID2.$ext;

} else {

echo "Error: upload did not work";

}

?>

我遇到的问题是我不断上传错误上传不起作用......我在这里做错了什么?这是我缺少的基本内容,但我需要了解它,因为我已经可以完成文件上传,但想了解它是如何工作的......

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值