$ _GET不工作在我的PHP [英] $_GET not working on my php
本文介绍了$ _GET不工作在我的PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将我的PHP调用到我的javascript代码中,我可以知道为什么 $ _ GET
不能在我的PHP文件中工作吗?
I Call my PHP into my javascript code, may I know why $_GET
not working in my PHP file?
我的URL是: localhost / img / index.php?fname = johndoe
strong> index.php 是:
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档案 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?
推荐答案
您试图读取 uploadimage中的数据。 php
但查询字符串在您的请求 index.php 。您必须将其包含在您要阅读的每个请求中。
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.
例如
$('#redactor_content').redactor({
imageUpload: 'uploadimage.php?fname=<?php echo isset($_GET['fname']) ? htmlspecialchars($_GET['fname']) : ""; ?>',
minHeight: 200 // pixels
});
这篇关于$ _GET不工作在我的PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文