普通网友 2016-05-14 17:01
浏览 32
已采纳

将图像上传到真实的Web服务器不起作用

I'm making a simple PHP application which can upload an image to server.

I did it in my localhost, everything works well, but when I did it in real server. I mean web.com, it didn't work.

Here is my PHP script :

<?php


require "init.php";

$encoded_string=$_POST["encoded_string"];
$userfname=$_POST["userNameOf"];

$decoded_string=base64_decode($encoded_string);

$string= str_replace(' ','', $userfname);

$path="http://mybookshare.com/photos/" .$string. ".jpg";




file_put_contents($path,$decoded_string);

$query = "UPDATE user SET ProfPicture='$encoded_string'  WHERE UserFN='$userfname' AND ProfPicture IS NULL";

$result = mysqli_query($conn, $query);

if($result) {
    echo "success";
} else {
    echo "failed";
}

mysqli_close($conn);
?>

The script is located in htdocs/app, and the upload file destination of the picture is at htdocs/photos

Any help please?

  • 写回答

1条回答 默认 最新

  • duanfei1930 2016-05-14 17:28
    关注

    Problem : You don't have photos directory as in your script directory.

    Solution : Try to move your photos directory from your sub directory to your script main directory where your PHP file is present and then you will have no errors.As you can see that the script says that your directory is not present so that's why it's failing to do the rest of process.

    Heads Up : I already said the same thing in my first comment but seems like you didn't give much attention to it.as you were mentioning the photos directory as to be present in your php script directory for your php to work it out with that and then you were not having the photos directory there so that's what was causing the error.!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作