续 - 将文件上传器添加到Joomla Admin Component
我能够上传文件并将其保存在磁盘上.但它不保存数据库中的文件名.
我该怎么做 ?
这是控制器 -
class InvoiceManagerControllerInvoiceManager extends JControllerForm
{
function save(){
$file = JRequest::getVar('jform', null, 'files', 'array');
$path = JPATH_BASE;
// Make the file name safe.
jimport('joomla.filesystem.file');
$file['name']['invoice'] = JFile::makeSafe($file['name']['invoice']);
// Move the uploaded file into a permanent location.
if (isset($file['name']['invoice'])) {
// Make sure that the full file path is safe.
$filepath = JPath::clean($path. DS ."components". DS ."com_invoicemanager". DS ."files". DS .strtolower($file['name']['invoice']));
// Move the uploaded file.
JFile::upload( $file['tmp_name']['invoice'], $filepath );
}
return …Run Code Online (Sandbox Code Playgroud) 我根据Joomla指南制作了Joomla管理组件 - http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Developing_a_Basic_Component
在那我需要有文件上传器,让用户上传单个文件.
在我定义的administrator\components\com_invoicemanager\models\forms\invoicemanager.xml中
<field name="invoice" type="file"/>
Run Code Online (Sandbox Code Playgroud)
在控制器管理员\ components\com_invoicemanager\controllers\invoicemanager.php我试图检索该文件,如下所示.但它无法正常工作(无法检索文件)
我在哪里做错了?
如何获取文件并将其保存在磁盘上?
class InvoiceManagerControllerInvoiceManager extends JControllerForm
{
function save(){
$file = JRequest::getVar( 'invoice', '', 'files', 'array' );
var_dump($file);
exit(0);
}
}
Run Code Online (Sandbox Code Playgroud) 我做了简单的python函数,它接受两个输入并输出一些文本.
这里是,
def weather():
israining_str=input("Is it raining (1 or 0) ? ")
israining = bool(israining_str)
temp_str=input("What is the temp ? ")
temp = float(temp_str)
if israining==True and temp<18:
return "Umbrella & Sweater"
elif israining==True and temp>=18:
return "Umbrella"
elif israining==False and temp<18:
return "Sweater"
else:
return "Cap"
Run Code Online (Sandbox Code Playgroud)
测试数据 -
>>>
Is it raining ? 0
What is the temp ? 43
Umbrella
>>> ================================ RESTART ================================
>>>
Is it raining ? 1
What is the temp ? 43
Umbrella
>>> …Run Code Online (Sandbox Code Playgroud) @echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a-%%b)
set mydir="%mydate%-%mytime%"
mkdir %mydir%
Run Code Online (Sandbox Code Playgroud)
使用上面的批处理脚本,我可以创建一个目录名称,如2015-05-14-11-30 AM
现在我需要将时间转换为 24 格式并删除 AM/PM
预期的文件夹名称 - 2015-05-14-11-30
怎么做 ?
我有一系列的答案,包括标记.
语法 - ["ANSWER1 | MARK1,ANSWER2 | MARK2 ...]
answers = ["Human machine interface for lab abc computer applications|3",
"A survey of user opinion of computer system response time|4",
"The EPS user interface management system|2",
"System and human system engineering testing of EPS|1"]
Run Code Online (Sandbox Code Playgroud)
我需要拆分这些并为每个答案提取标记.我该怎么做 ?
joomla ×2
joomla2.5 ×2
php ×2
python ×2
batch-file ×1
django ×1
file-upload ×1
windows ×1
xml ×1