将php变量传递给javascript语法问题

时间:2012-03-06 20:22:49

标签: php javascript

试图将图片上传到用户文件夹/上传/ $ uid我认为我有可变语法,可能文件路径中的语法不正确/ uploads / user /

(function($){
   $.simpleuploader = {version: '0.1'};
  $.fn.simpleuploader = function(options){
    // the container to inject the form into
    var $this = $(this);

    var user = '<?php echo $uid; ?>'; //is users id from session

    // set defults
    var defaults = {
        prefix: 'simpleuploader-',
        latency: 500,
        reuse: true,
        when: 'onchange',
        submitText: 'Submit',
        disabledOpacity: .3,
        settings: {
            fullPath: 'http://www.mysite.com/image_upload/uploads/user/',
            relPath: '../uploads/user/',

        },

1 个答案:

答案 0 :(得分:0)

在定义路径时是否尝试使用用户变量? 你应该这样做

var defaults = {
    prefix: 'simpleuploader-',
    latency: 500,
    reuse: true,
    when: 'onchange',
    submitText: 'Submit',
    disabledOpacity: .3,
    settings: {
        fullPath: 'http://www.mysite.com/image_upload/uploads/' + user + '/',
        relPath: '../uploads/' + user + '/',

    }