dongxi5423 2017-07-07 16:35
浏览 82
已采纳

php文件上传不起作用

I am testing a php code of file uploading. Here is the form:

<form action="C:/xampp/htdocs/php/upload.php" method="post" enctype="multipart/form-data">
    <p>Browse File</p>
    <p><input type="file" name="file" id="file" /></p>
    <p><input type="submit" name="submit" value="Submit" /></p>
</form>

and here is the upload.php file:

<?php
if($_POST['submit']){
$upload_folder = 'C:/xampp/htdocs/php/uploads/';
move_uploaded_file($_FILES['file']['tmp_name'], $upload_folder.$_FILES['file']['name']);
echo 'File uploaded successfully';
}
?>

But this doesn't upload any file. What is the problem here?

  • 写回答

2条回答 默认 最新

  • doushi5752 2017-07-07 16:37
    关注

    Take out the C: path and replace with a relative link to the location of your upload file.

    From your original post, if the location of your files on the local hardware is:

      htdocs/php/uploads/
    

    Then htdocs is probably the root, so / will point to the htdocs location, to get to your upload.php, you would specify:

      /php/uploads/upload.php
    

    However if htdocs isn't your root, then just adjust accordingly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 yolov5目标检测并显示目标出现的时间或视频帧
  • ¥15 电视版的优酷可以设置电影连续播放吗?
  • ¥50 复现论文;matlab代码编写
  • ¥30 echarts 3d地图怎么实现一进来页面散点数据和卡片一起轮播
  • ¥15 数字图像的降噪滤波增强
  • ¥15 心碎了,为啥我的神经网络训练的时候第二个批次反向传播会报错呀,第一个批次都没有问题
  • ¥15 MSR2680-XS路由器频繁卡顿问题
  • ¥15 VB6可以成功读取的文件,用C#读不了
  • ¥15 如何使用micpyhon解析Modbus RTU返回指定站号的湿度值,并确保正确?
  • ¥15 C++ 句柄后台鼠标拖动如何实现