通过C代码直接上传时,无法加载通过PHP代码上传的图像

时间:2018-09-06 03:27:07

标签: javascript php html cpanel web-hosting

我有用于将图片上传到我的网站的代码。图像已成功在localhost和远程主机上上传。但是问题是,当我在网页中显示图像时,它们在localhost中可以正常工作,而在远程主机中则不能工作。当我尝试通过URL(访问图像的完整路径)访问它时,它在localhost中工作正常,并在远程主机中显示404页面未找到错误。我尝试输入的网址是正确的,我也查看了正确上传的C面板文件夹中的图像。那是什么问题...?

当我在同一文件夹中手动上传一些图像,然后访问这些手动上传的图像时,它们工作正常。但是通过php代码上传的图像未加载...?下面是上传图像的完整代码。

<?php

include('connection.php');

if (isset($_POST['submit_images'])) {
    $name[1] = $_FILES['image1']['name'];
    $name[2] = $_FILES['image2']['name'];
    $name[3] = $_FILES['image3']['name'];
    $name[4] = $_FILES['image4']['name'];
    $name[5] = $_FILES['image5']['name'];
    $tmp_name[1] = $_FILES['image1']['tmp_name'];
    $tmp_name[2] = $_FILES['image2']['tmp_name'];
    $tmp_name[3] = $_FILES['image3']['tmp_name'];
    $tmp_name[4] = $_FILES['image4']['tmp_name'];
    $tmp_name[5] = $_FILES['image5']['tmp_name'];
    $success = 0;

    for ($c = 1; $c <= 5; $c++) {
        if (move_uploaded_file($tmp_name[$c], "../assets/uploaded_images/" . $name[$c])) {
              $success++;
        }
    }
    $id++;
    echo "<script>alert('$success images Uploaded');</script>";
    if ($id <= 10) {
        echo "<script>window.open('index.php?id=$id','_self')</script>";
    } else {
        echo "<h3 style='text-align:center;'>Thank You for Providing us the data.</h3>";
    }
}
?>

enter image description here

0 个答案:

没有答案