Php 将变量放入数组中
我是php新手,我一直坚持在数组中放入变量 我只想从变量中定义一个文件位置 我的变量下面的代码是$requested\u album,我知道我在下面输入的内容不正确,但我询问了多个人,似乎没有任何效果 请帮忙:)Php 将变量放入数组中,php,arrays,variables,Php,Arrays,Variables,我是php新手,我一直坚持在数组中放入变量 我只想从变量中定义一个文件位置 我的变量下面的代码是$requested\u album,我知道我在下面输入的内容不正确,但我询问了多个人,似乎没有任何效果 请帮忙:) 使用下面的代码。这是我的工作 $requested_album = "test"; $arr = array( 'limit' => 10, //Maximum Limit of files. {null, Number} 'maxSize' => 10,
使用下面的代码。这是我的工作
$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);
检查演示:
$uploader=新的上传程序()
$data=$uploader->upload($_FILES['FILES'],$arr)
试着用这个。使用-1 plz的原因?不是我。上面的方法不起作用,它没有看到变量,因此文件将保存在Forderhanks Ruchish的相册中!如何使其看起来像此albums/$requested_album/picture.jpg-请求的_album是foldercheck编辑的代码,请向上投票并接受答案@杰克斯托
$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
)
$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
);