You are not logged in.
Pages: 1
Dear BigTree users,
We have build another BigTree driven site, and we feel 100% comfortable and seasoned with BigTree. We've developed custom modules, etc.
BUT... we had never used the insert image > upload a file of the WYSIWYG interface. Simply never had a need for it.
On our latest site we do have that need, and it isn't working. Click upload and it stalls right there. Folder permissions on the server are fine.
Any idea where we can hunt to solve this?
Hope to hear from you, with warm regards,
Hans
Last edited by dynaread (February 24, 2016 1:12pm)
Offline
What version of BigTree are you running?
The file manager should hit a URL like "/admin/ajax/file-browser/upload/" when uploading -- do you get an HTTP error? If not, what is the response text?
Offline
Hi Tim,
Thanks for responding :-) Awesome! Hope you are well!
We're running Version 4.2.8
I'll share your info with our tasked engineer and will get back to you.
Thanks!
Hans
Offline
Good morning, Tim,
The file throwing the error sits in our /www/core/admin/ajax/file-browser/upload.php
Mozilla FireBug says...
Error (path = /admin/...upload/ (line 1) = SyntaxError: expected expression, got '<'
<br>
Any ideas, Tim? Absolutely no rush, as we choose to work with SFTP uploading of files for now, since the photo files require art work by my team anyways.
Warm greetings, and patiently awaiting your thoughts,
Hans
<?
$storage = new BigTreeStorage;
// If we're replacing an existing file, find out its name
if (isset($_POST["replace"])) {
$admin->requireLevel(1);
$replacing = $admin->getResource($_POST["replace"]);
$pinfo = BigTree::pathInfo($replacing["file"]);
$replacing = $pinfo["basename"];
// Set a recently replaced cookie so we don't use cached images
setcookie('bigtree_admin[recently_replaced_file]',true,time()+300,str_replace(DOMAIN,"",WWW_ROOT));
} else {
$replacing = false;
}
$folder = isset($_POST["folder"]) ? sqlescape($_POST["folder"]) : false;
$errors = array();
$successes = 0;
// This is an iFrame, so we're going to call the parent from it.
echo '<html><body><script>';
// If the user doesn't have permission to upload to this folder, throw an error.
$perm = $admin->getResourceFolderPermission($folder);
if ($perm != "p") {
echo 'parent.BigTreeFileManager.uploadError("You do not have permission to upload to this folder.");';
} else {
foreach ($_FILES["files"]["tmp_name"] as $number => $temp_name) {
$error = $_FILES["files"]["error"][$number];
$file_name = $replacing ? $replacing : $_FILES["files"]["name"][$number];
// Throw a growl error
if ($error) {
$file_name = htmlspecialchars($file_name);
if ($error == 2 || $error == 1) {
$errors[] = $file_name." was too large ".BigTree::formatBytes(BigTree::uploadMaxFileSize())." max)";
} else {
$errors[] = "Uploading $file_name failed (unknown error)";
}
// File successfully uploaded
} elseif ($temp_name) {
// See if this file already exists
if ($replacing || !$admin->matchResourceMD5($temp_name,$_POST["folder"])) {
$md5 = md5_file($temp_name);
// Get the name and file extension
$n = strrev($file_name);
$extension = strtolower(strrev(substr($n,0,strpos($n,"."))));
// See if it's an image
list($iwidth,$iheight,$itype,$iattr) = getimagesize($temp_name);
// It's a regular file
if ($itype != IMAGETYPE_GIF && $itype != IMAGETYPE_JPEG && $itype != IMAGETYPE_PNG) {
$type = "file";
if ($replacing) {
$file = $storage->replace($temp_name,$file_name,"files/resources/");
} else {
$file = $storage->store($temp_name,$file_name,"files/resources/");
}
// If we failed, either cloud storage upload failed, directory permissions are bad, or the file type isn't permitted
if (!$file) {
if ($storage->DisabledFileError) {
$errors[] = "$file_name has a disallowed extension: $extension.";
} else {
$errors[] = "Uploading $file_name failed (unknown error).";
}
// Otherwise make the database entry for the file we uplaoded.
} else {
if (!$replacing) {
$admin->createResource($folder,$file,$md5,$file_name,$extension);
}
}
// It's an image
} else {
$type = "image";
// We're going to create a list view and detail view thumbnail plus whatever we're requesting to have through Settings
$thumbnails_to_create = array(
"bigtree_internal_list" => array("width" => 100, "height" => 100, "prefix" => "bigtree_list_thumb_"),
"bigtree_internal_detail" => array("width" => 190, "height" => 145, "prefix" => "bigtree_detail_thumb_")
);
$more_thumb_types = $cms->getSetting("bigtree-file-manager-thumbnail-sizes");
if (is_array($more_thumb_types)) {
foreach ($more_thumb_types as $thumb) {
$thumbnails_to_create[$thumb["title"]] = $thumb;
}
}
// Do lots of image awesomesauce.
$itype_exts = array(IMAGETYPE_PNG => ".png", IMAGETYPE_JPEG => ".jpg", IMAGETYPE_GIF => ".gif");
$first_copy = $temp_name;
list($iwidth,$iheight,$itype,$iattr) = getimagesize($first_copy);
foreach ($thumbnails_to_create as $thumb) {
// We don't want to add multiple errors and we also don't want to waste effort getting thumbnail sizes if we already failed.
if (!$error) {
$sizes = BigTree::getThumbnailSizes($first_copy,$thumb["width"],$thumb["height"]);
if (!BigTree::imageManipulationMemoryAvailable($first_copy,$sizes[3],$sizes[4],$iwidth,$iheight)) {
$errors[] = "$file_name is too large for the server to manipulate. Please upload a smaller version of this image.";
unlink($first_copy);
}
}
}
if (!$error) {
// Now let's make the thumbnails we need for the image manager
$thumbs = array();
$pinfo = BigTree::pathInfo($file_name);
// Create a bunch of thumbnails
foreach ($thumbnails_to_create as $key => $thumb) {
if ($iwidth > $thumb["width"] || $iheight > $thumb["height"]) {
$temp_thumb = SITE_ROOT."files/".uniqid("temp-").$itype_exts[$itype];
BigTree::createThumbnail($first_copy,$temp_thumb,$thumb["width"],$thumb["height"]);
if ($replacing) {
$file = $storage->replace($temp_thumb,$thumb["prefix"].$pinfo["basename"],"files/resources/");
} else {
$file = $storage->store($temp_thumb,$thumb["prefix"].$pinfo["basename"],"files/resources/");
}
$thumbs[$key] = $file;
}
}
// Upload the original to the proper place.
if ($replacing) {
$file = $storage->replace($first_copy,$file_name,"files/resources/");
} else {
$file = $storage->store($first_copy,$file_name,"files/resources/");
}
if (!$file) {
$errors[] = "Uploading ".htmlspecialchars($file_name)." failed (unknown error).";
} else {
if (!$replacing) {
$admin->createResource($folder,$file,$md5,$file_name,$extension,"on",$iheight,$iwidth,$thumbs);
} else {
$admin->updateResource($_POST["replace"],array(
"date" => date("Y-m-d H:i:s"),
"md5" => $md5,
"height" => $iheight,
"width" => $iwidth,
"thumbs" => BigTree::json($thumbs)
));
}
}
}
}
}
}
}
}
if (count($errors)) {
$uploaded = count($_FILES["files"]["tmp_name"]) - count($errors);
$success_message = "$uploaded file".($uploaded != 1 ? "s" : "")." uploaded successfully.";
echo 'parent.BigTreeFileManager.uploadError("'.implode("<br />",$errors).'","'.$success_message.'");</script></body></html>';
} else {
echo 'parent.BigTreeFileManager.finishedUpload('.json_encode($errors).');</script></body></html>';
}
?>
Offline
Sorry for the delayed reply, for some reason I didn't get an email notification.
My best guess is that you're getting some kind of warning message and have BigTree's debug turned on. Would it be possible to get the full text from the HTTP response? It looks like a notice can be thrown in my dev environment if you explicitly turn all error messages on but that it still functions -- I'm guessing there's an issue that isn't the simple notice that's causing it to fail. Maybe image thumbnailing?
To that matter, do you have any error messages when you go to the Developer tab and click the Site Status option in the Debug area? It's possible your server has an issue with a missing PHP module (i.e. cURL or GD is missing).
Offline
Thanks, Tim, we're exploring further. Thanks so much!! Have a super day.
Offline
Hi Tim, I have installed BigTree on a NearlyFreeSpeech hosting account, and I'm experiencing the same errors as above in the /core/admin/ajax/file-browser/upload.php file. It appears that there is something weird about the /tmp folder permissions? I set up and linked to a Google Cloud Storage service to see if that would clear up the issues, but it doesn't appear to help. My hosting account limits permission to most folders outside of the /public folder. To expand upon the previous person's request, I noticed the following is shown in the file_manager_upload_frame iframe as well:
<html><head></head><body><script><br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1105</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1321</b><br />
<br />
<b>Warning</b>: unlink(/home/tmp/phpaQFUxt): No such file or directory in <b>/home/public/core/admin/ajax/file-browser/upload.php</b> on line <b>102</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1105</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1321</b><br />
<br />
<b>Warning</b>: unlink(/home/tmp/phpaQFUxt): No such file or directory in <b>/home/public/core/admin/ajax/file-browser/upload.php</b> on line <b>102</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1105</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1321</b><br />
<br />
<b>Warning</b>: unlink(/home/tmp/phpaQFUxt): No such file or directory in <b>/home/public/core/admin/ajax/file-browser/upload.php</b> on line <b>102</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1105</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1321</b><br />
<br />
<b>Warning</b>: unlink(/home/tmp/phpaQFUxt): No such file or directory in <b>/home/public/core/admin/ajax/file-browser/upload.php</b> on line <b>102</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1105</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1321</b><br />
<br />
<b>Warning</b>: fopen(/home/public/site/files/temp-57b00a2e9aa27.png): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>874</b><br />
<br />
<b>Warning</b>: filesize(): stat failed for /home/public/site/files/temp-57b00a2e9aa27.png in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>875</b><br />
<br />
<b>Warning</b>: curl_setopt(): supplied argument is not a valid File-Handle resource in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>436</b><br />
<br />
<b>Warning</b>: fclose() expects parameter 1 to be resource, boolean given in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>884</b><br />
<br />
<b>Warning</b>: unlink(/home/public/site/files/temp-57b00a2e9aa27.png): No such file or directory in <b>/home/public/core/inc/bigtree/apis/storage.php</b> on line <b>240</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1105</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1321</b><br />
<br />
<b>Warning</b>: fopen(/home/public/site/files/temp-57b00a2eab7e5.png): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>874</b><br />
<br />
<b>Warning</b>: filesize(): stat failed for /home/public/site/files/temp-57b00a2eab7e5.png in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>875</b><br />
<br />
<b>Warning</b>: curl_setopt(): supplied argument is not a valid File-Handle resource in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>436</b><br />
<br />
<b>Warning</b>: fclose() expects parameter 1 to be resource, boolean given in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>884</b><br />
<br />
<b>Warning</b>: unlink(/home/public/site/files/temp-57b00a2eab7e5.png): No such file or directory in <b>/home/public/core/inc/bigtree/apis/storage.php</b> on line <b>240</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1105</b><br />
<br />
<b>Warning</b>: getimagesize(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>1321</b><br />
<br />
<b>Warning</b>: fopen(/home/public/site/files/temp-57b00a2eba1d2.png): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>874</b><br />
<br />
<b>Warning</b>: filesize(): stat failed for /home/public/site/files/temp-57b00a2eba1d2.png in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>875</b><br />
<br />
<b>Warning</b>: curl_setopt(): supplied argument is not a valid File-Handle resource in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>436</b><br />
<br />
<b>Warning</b>: fclose() expects parameter 1 to be resource, boolean given in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>884</b><br />
<br />
<b>Warning</b>: unlink(/home/public/site/files/temp-57b00a2eba1d2.png): No such file or directory in <b>/home/public/core/inc/bigtree/apis/storage.php</b> on line <b>240</b><br />
<br />
<b>Warning</b>: fopen(/home/tmp/phpaQFUxt): failed to open stream: No such file or directory in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>874</b><br />
<br />
<b>Warning</b>: filesize(): stat failed for /home/tmp/phpaQFUxt in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>875</b><br />
<br />
<b>Warning</b>: curl_setopt(): supplied argument is not a valid File-Handle resource in <b>/home/public/core/inc/bigtree/utils.php</b> on line <b>436</b><br />
<br />
<b>Warning</b>: fclose() expects parameter 1 to be resource, boolean given in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/public/core/inc/bigtree/apis/cloud-storage.php</b> on line <b>884</b><br />
<br />
<b>Warning</b>: unlink(/home/tmp/phpaQFUxt): No such file or directory in <b>/home/public/core/inc/bigtree/apis/storage.php</b> on line <b>240</b><br />
parent.BigTreeFileManager.uploadError("site-logo.png is too large for the server to manipulate. Please upload a smaller version of this image.<br />site-logo.png is too large for the server to manipulate. Please upload a smaller version of this image.<br />site-logo.png is too large for the server to manipulate. Please upload a smaller version of this image.<br />site-logo.png is too large for the server to manipulate. Please upload a smaller version of this image.<br />site-logo.png is too large for the server to manipulate. Please upload a smaller version of this image.<br />Uploading site-logo.png failed (unknown error).","-5 files uploaded successfully.");</script></body></html>
Could I possibly set up a /tmp folder inside of the /home/public/ site root, instead of in /home/tmp/? Maybe I'm incorrect in my assumption though. Any help is appreciated. FYI, the file I'm attempting to upload is only 7-8 kb, so I don't think it's a file size issue.
Thanks as usual.
Offline
The first set of errors about /home/tmp/ seem to indicate that PHP is pointing at the incorrect temporary upload directory (where user uploaded files are stored before BigTree even touches them -- corresponding to upload_tmp_dir in php.ini). If you have the ability to set any php flags (i.e. in htaccess or php.ini) that's the first thing I'd adjust - point it someplace writable by the web server (it's usually /tmp -- not /home/tmp).
Offline
Pages: 1