Browse files

Fixed file upload issues when open_basedir restriction is enabled.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@40603 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 2748b0e commit 15d8a4b8f6025a645e02fc6cf649cbf6b8cb3fc0 @ajoneil ajoneil committed Aug 21, 2007
Showing with 17 additions and 3 deletions.
  1. +17 −3 code/AssetAdmin.php
View
20 code/AssetAdmin.php
@@ -137,11 +137,25 @@ function doUpload($data, $form) {
if($data['ID'] && $data['ID'] != 'root') $folder = DataObject::get_by_id("Folder", $data['ID']);
else $folder = singleton('Folder');
- $warnFiles = array();
+ $newFiles = array();
$fileSizeWarnings = '';
-
+ $uploadErrors = '';
+
foreach($processedFiles as $file) {
+ if($file['error'] == UPLOAD_ERR_NO_TMP_DIR) {
+ $status = 'bad';
+ $statusMessage = 'There is no temporary folder for uploads. Please set upload_tmp_dir in php.ini.';
+ break;
+ }
+
if($file['tmp_name']) {
+ // Workaround open_basedir problems
+ if(ini_get("open_basedir")) {
+ $newtmp = TEMP_FOLDER . '/' . $file['name'];
+ move_uploaded_file($file['tmp_name'], $newtmp);
+ $file['tmp_name'] = $newtmp;
+ }
+
// check that the file can be uploaded and isn't too large
$extensionIndex = strripos( $file['name'], '.' );
@@ -175,7 +189,7 @@ function doUpload($data, $form) {
$numFiles = sizeof($newFiles);
$statusMessage = "Uploaded $numFiles files";
$status = "good";
- } else {
+ } else if($status != 'bad') {
$statusMessage = "There was nothing to upload";
$status = "";
}

0 comments on commit 15d8a4b

Please sign in to comment.