2016-05-17 203 views
0

我是新來的PHP,我只能堅持把一個變量的陣列把一個變量數組

所有我想要做的就是從變量

定義文件的位置看並且我的變量下面的代碼是$ requested_album,我知道我在下面放的是不正確的,但我問多個人,似乎沒有任何工作!

請幫助下面的代碼:)

$uploader = new Uploader(); 
     $data = $uploader->upload($_FILES['files'], array(
      'limit' => 10, //Maximum Limit of files. {null, Number} 
      'maxSize' => 10, //Maximum Size of files {null, Number(in MB's)} 
      'extensions' => null, //Whitelist for file extension. {null, Array(ex: array('jpg', 'png'))} 
      'required' => false, //Minimum one file is required for upload {Boolean} 
      'uploadDir' => "../albums/$requested_album", //Upload directory {String} 
      'title' => array('name'), //New file name {null, String, Array} *please read documentation in README.md 
      'removeFiles' => true, //Enable file exclusion {Boolean(extra for jQuery.filer), String($_POST field name containing json data with file names)} 
      'perms' => null, //Uploaded file permisions {null, Number} 
      'onCheck' => null, //A callback function name to be called by checking a file for errors (must return an array) | ($file) | Callback 
      'onError' => null, //A callback function name to be called if an error occured (must return an array) | ($errors, $file) | Callback 
      'onSuccess' => null, //A callback function name to be called if all files were successfully uploaded | ($files, $metas) | Callback 
      'onUpload' => null, //A callback function name to be called if all files were successfully uploaded (must return an array) | ($file) | Callback 
      'onComplete' => null, //A callback function name to be called when upload is complete | ($file) | Callback 
      'onRemove' => 'onFilesRemoveCallback' //A callback function name to be called by removing files (must return an array) | ($removed_files) | Callback 
     )); 

回答

-1

使用。它爲我工作。

$requested_album = "test"; 
$arr = array(
    'limit' => 10, //Maximum Limit of files. {null, Number} 
    'maxSize' => 10, //Maximum Size of files {null, Number(in MB's)} 
    'extensions' => null, //Whitelist for file extension. {null, Array(ex: array('jpg', 'png'))} 
    'required' => false, //Minimum one file is required for upload {Boolean} 
    'uploadDir' => "../albums/".$requested_album."/picture.jpg", //Upload directory {String} 
    'title' => array('name'), //New file name {null, String, Array} *please read documentation in README.md 
    'removeFiles' => true, //Enable file exclusion {Boolean(extra for jQuery.filer), String($_POST field name containing json data with file names)} 
    'perms' => null, //Uploaded file permisions {null, Number} 
    'onCheck' => null, //A callback function name to be called by checking a file for errors (must return an array) | ($file) | Callback 
    'onError' => null, //A callback function name to be called if an error occured (must return an array) | ($errors, $file) | Callback 
    'onSuccess' => null, //A callback function name to be called if all files were successfully uploaded | ($files, $metas) | Callback 
    'onUpload' => null, //A callback function name to be called if all files were successfully uploaded (must return an array) | ($file) | Callback 
    'onComplete' => null, //A callback function name to be called when upload is complete | ($file) | Callback 
    'onRemove' => 'onFilesRemoveCallback' //A callback function name to be called by removing files (must return an array) | ($removed_files) | Callback 
); 
echo "<pre>"; 
print_r($arr); 

輸出

Array 
(
    [limit] => 10 
    [maxSize] => 10 
    [extensions] => 
    [required] => 
    [uploadDir] => ../albums/test/picture.jpg 
    [title] => Array 
     (
      [0] => name 
     ) 

    [removeFiles] => 1 
    [perms] => 
    [onCheck] => 
    [onError] => 
    [onSuccess] => 
    [onUpload] => 
    [onComplete] => 
    [onRemove] => onFilesRemoveCallback 
) 

檢查演示:Click Here

+0

原因爲-1 plz? – RJParikh

+0

不是我。以上不起作用,它沒有看到變量,所以該文件將保存在相冊forfor –

+0

謝謝Ruchish!如何使它看起來像這個相冊/.$ requested_album/picture.jpg - requested_album是文件夾 –

0
$arr = array(
       'limit' => 10, //Maximum Limit of files. {null, Number} 
       'maxSize' => 10, //Maximum Size of files {null, Number(in MB's)} 
       'extensions' => null, //Whitelist for file extension. {null, Array(ex: array('jpg', 'png'))} 
       'required' => false, //Minimum one file is required for upload {Boolean} 
       'uploadDir' => "../albums/".$requested_album, //Upload directory {String} 
       'title' => array('name'), //New file name {null, String, Array} *please read documentation in README.md 
       'removeFiles' => true, //Enable file exclusion {Boolean(extra for jQuery.filer), String($_POST field name containing json data with file names)} 
       'perms' => null, //Uploaded file permisions {null, Number} 
       'onCheck' => null, //A callback function name to be called by checking a file for errors (must return an array) | ($file) | Callback 
       'onError' => null, //A callback function name to be called if an error occured (must return an array) | ($errors, $file) | Callback 
       'onSuccess' => null, //A callback function name to be called if all files were successfully uploaded | ($files, $metas) | Callback 
       'onUpload' => null, //A callback function name to be called if all files were successfully uploaded (must return an array) | ($file) | Callback 
       'onComplete' => null, //A callback function name to be called when upload is complete | ($file) | Callback 
       'onRemove' => 'onFilesRemoveCallback' //A callback function name to be called by removing files (must return an array) | ($removed_files) | Callback 
      ); 

$上傳=新上傳();

$ data = $ uploader-> upload($ _ FILES ['files'],$ arr);

嘗試使用這一個。

相關問題