结合javascript/jQuery和PHP [英] Combining javascript / jQuery and PHP
本文介绍了结合javascript/jQuery和PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Uploadify上传图片.现在,我需要获取正确的上传路径.
I'm using Uploadify to upload an image. Now I need to get the correct upload path.
我有以下代码/脚本:
<?php
$uploadifyPath = get_bloginfo('url') . '/wp-content/plugins/uploadify/';
$galleryPath = "'".getGalleryURL('1620')."'"; // <--- 1620 is inputed by me.
?>
<input id="galleryID" type="hidden" value="1620" name="galleryID"/>
<input id="fileInput" name="fileInput" type="file" />
<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
$('#fileInput').uploadify({
'uploader' : '<?php echo $uploadifyPath ?>uploadify.swf',
'script' : '<?php echo $uploadifyPath ?>uploadify.php',
'cancelImg' : '<?php echo $uploadifyPath ?>cancel.png',
'auto' : true,
'folder' : <?php echo $galleryPath ?>
});
});
// ]]></script>
我如何使用jQuery获取galleryID的值并将其输入到函数getGalleryURL()
中?
How can I, with jQuery, get the value of galleryID and input it into my function getGalleryURL()
?
或者...有更好的方法吗?
Or... is there a better way to do this??
推荐答案
通过jQuery进行AJAX调用,以使PHP知道galleryID,然后使用其回调来加载uploadify.
Do an AJAX call via jQuery to let PHP know the galleryID and then use it's callback to load uploadify.
这篇关于结合javascript/jQuery和PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文