Uploadify没有传递变量,Session有问题吗? [英] Uploadify not passing variables, Session problem?

查看:146
本文介绍了Uploadify没有传递变量,Session有问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于对pete的热爱,我无法接受它接受任何变量到我的SQL数据库中.如果我输入静态信息,它将起作用.我似乎无法通过scriptdata传递任何参数,这使它更具挑战性,因为我在顶部使用了smarty模板系统.

For the love of pete I can't get it to accept any variables into to my SQL db. If I put static info it works. I can't seem to pass any paramaters over with scriptdata and it makes it more challenging because I'm using smarty template system on top.

我正在尝试这样做.

 {literal}
<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery("#fileUpload").uploadify({

        'scriptData'     :{'alb_id': '{/literal}$alb_id{literal}','mem_id': '{/literal}$info.mem_id{literal}'},
        'uploader': '/ajax/upload/uploadify.swf',
        'cancelImg': '/ajax/upload/cancel.png',
        'script': '/ajax/upload/uploader.php',
        'folder': 'photos',
        'multi': true,
        'displayData': 'speed',
        'fileDesc'  : 'Image Files',
        'fileExt': '*.jpg;*.jpeg;',
        'simUploadLimit': 200,
        'width'          : 130,
        'queueID'        : 'fileQueue',
        'buttonImg': '/themes/mytheme/gfx/buttons/but_browse.gif'       
    });

});
</script>
{/literal}

在我的模板文件中.上传部分工作正常.只是没有mysql.我正在使用脚本中内置的功能来调整缩略图和其他内容的大小,并建立目录.一切正常.它只是不会将任何变量传递给数据库.

In my template file. The upload part works fine. Just not the mysql. I am using a function built into the script to resize images for thumbnailes and what not and build a directory. All that works. It just won't pass any variables to the db.

include_once("../../includes/config/config.inc.php");
    //load libraries
include(DOC_ROOT."/libraries.php");


$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS,1);
mysql_select_db(SQL_DB,$conn);

$alb_id = $_REQUEST['alb_id'];
$mem_id = $_REQUEST['mem_id'];  


if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];

        $extension = ".jpeg";
        $photo = build_thumbnailes($tempFile,$extension);

        $sql ="INSERT INTO `photos`(`mem_id`, `photo`, `photo_med`, `photo_small`, `approved`,`posted`, `upload_date`) 
        VALUES 
        ('$alb_id', '".$photo["ex"]."', '".$photo["med"]."','".$photo["small"]."' , '1', time(), time())";
        mysql_query($sql) or die(mysql_error());

如果可以的话,请提供帮助.我为这件事疯狂.谢谢.

Please help if you can. I'm going crazy with this thing. Thanks.

推荐答案

好吧,我不知道这是否是答案",但确实有一些问题.

Well I don't know if this is the "answer" but I do see a couple of problems.

  1. 在您的模板中,您具有:

  1. In your template you have:

'scriptData': {'alb_id': '{/literal}$alb_id{literal}',
               'mem_id': '{/literal}$info.mem_id{literal}'},

您的聪明变量$alb_id$info.mem_id将按字面传递(而不是其值).您需要:

Your smarty variables $alb_id and $info.mem_id are going to be passed literally (instead of their values). You need:

'scriptData': {'alb_id': '{/literal}{ $alb_id }{literal}',
               'mem_id': '{/literal}{ $info.mem_id }{literal}'},

  • 第二,您应该检查文件是否确实是PHP中的上载文件.代替:

  • Secondly you should be checking if your file is truly an uploaded file in your PHP. Instead of:

    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
    

    使用:

    if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
    

  • 我真的怀疑您没有从您认为要获取的表单中获取数据.您怎么知道上传正常?您如何知道这些值是从表单传递的?您可能需要从表单中打印出变量,以查看是否确实得到了期望的结果.

    I really suspect you aren't getting the data from the form you think you're getting. How do you know the upload is working? How do you know the values were passed from the form? You might want to print out the variables from the form to see if you're really getting what you expect.

    您从MySQL得到错误消息吗?还是只是没有显示数据?在此处提供更多信息可能会给您带来更好的答案.

    Do you get an error from MySQL? Or is it that the data just doesn't show up? Providing some more info might get you some better answers here.

    这篇关于Uploadify没有传递变量,Session有问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆