uploadify session java,Uploadify没有传递变量,Session有问题吗?

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.

I was trying to do this.

{literal}

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'

});

});

{/literal}

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.

In your template you have:

'scriptData': {'alb_id': '{/literal}$alb_id{literal}',

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

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}'},

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'];

Use:

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值