我正在以多步形式将数据提交到数据库以及图像,但我被卡住了, 视图:
<?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中的新表,我想保存image_name,类型,大小和数据。 现在问题是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
),
anonymous.png是选定的文件。
任何帮助请我被困?提前谢谢。