我正在以多步形式将数据提交到数据库以及图像,但我被卡住了,查看:
<?php
echo $this->Form->file('File',array(
'placeholder'=>'Upload Profile',
'accept'=>''
))
?>
这是用户完成所有步骤后的控制器代码:
<?php
if (!empty($currentSessionData['Post']['File']) &&
is_uploaded_file($currentSessionData['Post']['File']['tmp_name'])) {
$fileData = fread(fopen($currentSessionData['Post']['File']['tmp_name'], "r"),
$currentSessionData['Post']['File']['size']);
$this->request->data[$table_name]['image_name'] = $currentSessionData['Post']['File']['name'];
$this->request->data[$table_name]['image_type'] = $currentSessionData['Post']['File']['type'];
$this->request->data[$table_name]['image_size'] = $currentSessionData['Post']['File']['size'];
$this->request->data[$table_name]['image_data'] = $fileData;
}
我正在使用 Post Model 获取输入并将数据保存到我使用 cakephp 中的 loadModel() 方法加载的其他表中。现在这里 $currentSessionData 是会话数据,一旦用户完成所有步骤,我将保存所有步骤的用户数据,然后它会进入控制器中的保存部分。$tablename 是 phpmyadmin 中的新表,我想在其中保存图像名称、类型、大小和数据。现在问题是 is_uploaded_file() 方法返回 false 吗?$currentSessionData 返回:
'File' => array(
'name' => 'anonymous.png',
'type' => 'image/png',
'tmp_name' => 'C:\wamp\tmp\php2D7E.tmp',
'error' => (int) 0,
'size' => (int) 983
),
匿名.png 是选定的文件。
任何帮助,请我被卡住了吗?提前致谢。