duanmu6752 2016-05-20 19:07 采纳率: 0%
浏览 58
已采纳

无法将文件从移动版本上传到经典版本目录,同一域名

im currently having an issue with the upload of files from the mobile version of the site im currently working with, I think the issue is related to the fact that the mobile version files are outside the public_hmtl folder inside a folder named m, this was done like this because the m.site.com link wouldnt work otherwise, since im using the classic site folder to store all the media, the problem starts here:

heres the path im working with:

  • /
  • /m
  • /public_html

the file in

  • /m/user/fnc/upload.php

is directed to save an img to

  • /public_html/photos/users/

here's a fragment of the code in upload.php for the first line, I use a redirect variable called $img that leads to the index of the classic version, that would be

  • www.mysite.com/

so

$URL = $img.'photos/users/';
$NewFotoName = "misite_".$usuarioid."_".time().".jpg";

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $imagen = $_POST['Imagen'];
    if ( isset($_POST['Imagen']) ) {
        $image = base64_decode($imagen);
        $im = imagecreatefromstring($image);
        imagepng($im,$URL.$NewFotoName);
        imagedestroy($im);

        $query = "UPDATE Utenti SET foto = '$NewFotoName' WHERE id_utente = ".$usuarioid;
        $result = $mysqli->query($query);
        if(!$result){die($mysqli->error);}
        echo "index2.php";
                die();
    } else {
        echo "index2.php";
                die();          
    }
} else {
    echo "index2.php";
                die();
}

and i call it from a file one folder above it called index2.php with this code:

$('.upload-result').on('click', function (ev) {
            $uploadCrop.croppie('result', {
                type: 'canvas',
                size: 'original'
            }).then(function (resp) {
                $('#imagebase64').val(resp);
                var imagen_cortada = $('#imagebase64').val();
                var base64image = imagen_cortada;
                var parametros = { "Imagen" : base64image };
                $.ajax({
                    data: { "Imagen" : output },
                    url: 'fnc/upload.php',
                    method: 'POST', // or GET
                    success: function(msg) 
                    {
                        alert("Imagen subida con exito.");
                        alert(msg);
                    },
                    error: function (jqXHR, textStatus, errorThrown)
                    {
                        alert("Error al Subir la Imagen.");
                        alert(errorThrown);
                        window.location.replace(msg);
                    }
                });

now when the form is submited I get a succes alert but in the "alert(msg);" I get an error that says

imagepng(path/to/the/file.png): failed to open stream; no such file or directory in /home/mysite/m/user/fnc/upload.php

So the name of the file gets saved into the database but the file doesnt.

I appreciate any suggestions, excuse any spelling mistakes.

//edit I found a work arround and moved the subdomaind directory inside public_html, had to learn a bit about the .htacces, it seems this way i will not have all those pesky permision problems

  • 写回答

1条回答 默认 最新

  • dtr53557 2016-05-23 18:22
    关注

    I found a work arround and moved the subdomaind directory inside public_html, had to learn a bit about the .htacces, it seems this way i will not have all those pesky permision problems, the other workarrounds posted in the similar thread Vic Seedoubleyew posted didnt seem to do the trick for me

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

报告相同问题?

悬赏问题

  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛