普通网友 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 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题