Pluf Framework

Pluf Framework Commit Details


Date:2008-11-12 13:38:22 (16 years 1 month ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:40d07a8e21bb5a2a91aa4e5d0e96620236d0d9da
Parents: fe2351e157c1dff04de9def07eeea1ace5c03755
Message:Fixed some small issues in the creation of the path and requirement checking.

Changes:

File differences

src/Pluf/Form/Field/File.php
5050
5151
5252
53
53
54
55
56
57
5458
5559
5660
......
110114
111115
112116
113
114
115
116
117
118
119
120
121117
122118
123119
......
125121
126122
127123
124
125
126
128127
128
129
130
131
132
133
129134
130135
131136
132
137
133138
134139
135140
throw new Pluf_Form_Invalid(__('The upload did not complete. Please try to send the file again.'));
break;
case UPLOAD_ERR_NO_FILE:
throw new Pluf_Form_Invalid(__('No files were uploaded. Please try to send the file again.'));
if ($this->required) {
throw new Pluf_Form_Invalid(__('No files were uploaded. Please try to send the file again.'));
} else {
return ''; // no file
}
break;
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_CANT_WRITE:
{
$name = Pluf_Utils::cleanFileName($value['name']);
$upload_path = Pluf::f('upload_path', '/tmp');
if (isset($params['upload_path'])) {
$upload_path = $params['upload_path'];
}
if (isset($params['upload_path_create']) and !is_dir($upload_path)) {
if (false == @mkdir($upload_path, 0777, true)) {
throw new Pluf_Form_Invalid(__('An error occured when creating the upload path. Please try to send the file again.'));
}
}
if (isset($params['file_name'])) {
if (false !== strpos($params['file_name'], '%s')) {
$name = sprintf($params['file_name'], $name);
$name = $params['file_name'];
}
}
if (isset($params['upload_path'])) {
$upload_path = $params['upload_path'];
}
$dest = $upload_path.'/'.$name;
if (isset($params['upload_path_create'])
and !is_dir(dirname($dest))) {
if (false == @mkdir(dirname($dest), 0777, true)) {
throw new Pluf_Form_Invalid(__('An error occured when creating the upload path. Please try to send the file again.'));
}
}
if ((!isset($params['upload_overwrite']) or $params['upload_overwrite'] == false) and file_exists($dest)) {
throw new Pluf_Form_Invalid(sprintf(__('A file with the name "%s" has already been uploaded.'), $name));
}
if (!@move_uploaded_file($value['tmp_name'], $dest)) {
if (@!move_uploaded_file($value['tmp_name'], $dest)) {
throw new Pluf_Form_Invalid(__('An error occured when uploading the file. Please try to send the file again.'));
}
@chmod($dest, 0666);

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.06918s using 13 queries.