dongyu2047 2015-08-08 16:18
浏览 20
已采纳

$ _GET无法处理我的php

I Call my PHP into my javascript code, may I know why $_GET not working in my PHP file?

My URL is : localhost/img/index.php?fname=johndoe

Javascript inside my index.php is :

<script src="uploadname.js"></script>
<script type="text/javascript">
$(document).ready(
    function()
    {
        $(\'#redactor_content\').redactor({
            imageUpload: \'uploadimage.php\',
            minHeight: 200 // pixels
        });
    }
);
</script> 

php file uploadimage.php

<?php

    $fname=$_GET['fname'];
    $dir = '../assets/uploads/r/';
    $sysUrl = lc('sysUrl');

    $_FILES['file']['type'] = strtolower($_FILES['file']['type']);

    if ($_FILES['file']['type'] == 'image/png'
    || $_FILES['file']['type'] == 'image/jpg'
    || $_FILES['file']['type'] == 'image/gif'
    || $_FILES['file']['type'] == 'image/jpeg'
    || $_FILES['file']['type'] == 'image/pjpeg')
    {
        // setting file's mysterious name
        $filename = $fname.date('YmdHis').'.jpg';
        $file = $dir.$filename;

        // copying
        copy($_FILES['file']['tmp_name'], $file);

        // displaying file
        $array = array(
            'filelink' => $sysUrl.'/assets/uploads/r/'.$filename
        );

        echo stripslashes(json_encode($array));

    }

?>

I've used above code but when I save the file it shows blank. got nothing may I know the reason why?

展开全部

  • 写回答

1条回答 默认 最新

  • dovt85093 2015-08-11 01:44
    关注

    You are trying to read the data inside uploadimage.php but the query string is on your request to index.php. You have to include it in each request you want to read it from.

    e.g.

    $('#redactor_content').redactor({
        imageUpload: 'uploadimage.php?fname=<?php echo isset($_GET['fname']) ? htmlspecialchars($_GET['fname']) : ""; ?>',
        minHeight: 200 // pixels
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部