dongyu2047 2015-08-09 00: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 09: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
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CSS通配符清除内外边距为什么可以覆盖默认样式?
  • ¥15 SPSS分类模型实训题步骤
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红
  • ¥15 想问问富文本拿到的html怎么转成docx的