7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » New file upload doesnt work but choose existing files works
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 677 Views |
-
New file upload doesnt work but choose existing files works

16 January 2012 at 6:00am
Hi,
I was hoping if someone else had the same problem and could help me out.
To start with I have updated dataobject_manager, image_gallery and uploadify from github.
When I try to upload a new image it doesn't get attached after upload. However if I choose from existing I am able to import and works as expected.
I have cross checked db & folder, the file is successfully uploaded but for some reason doesn't attach itself.
My GalleryImage.php
class GalleryImage extends DataObject
{
static $db = array (
'ImageTitle' => 'Text',
);static $default_parent = null; // NOTE: has to be a URL segment NOT a class name
static $can_be_root = FALSE;
static $has_one = array (
'MyGalleryImage' => 'Image', //relation needed for this DataObject
//'BelongToEventPage' => 'EventPage' //relation needed to point back to your pagetype, my pagetype is EventPage.
'BelongToBlogEntryPage' => 'BlogEntry'
);public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('ImageTitle'),
new FileIFrameField('MyGalleryImage')
);
}
}.....
static $has_many = array (
'GalleryImages' => 'GalleryImage'
);.....
function getCMSFields() {
$manager = new ImageDataObjectManager(
$this, // Controller
'GalleryImages', // Source name
'GalleryImage', // Source class
'MyGalleryImage', // File name on DataObject
array(
'GalleryImageTitle' => 'GalleryImageTitle'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab('Root.Content.GalleryImage', $manager);
return $fields;
}.....
-
Re: New file upload doesnt work but choose existing files works

16 January 2012 at 9:22am
I´ve got the same problem a time ago. Check that you doesn´t close the <?php
Check if you doesn´t have at the end of your php-files " ?> ". -
Re: New file upload doesnt work but choose existing files works

16 January 2012 at 10:56am
I've had this problem before too, and similar to Bereusei it had to do with the php tags. My exact problem was that on one of my page class files I had the opening '<?php' on the second line of the document. Moving it up to the first line solved the problem.
-
Re: New file upload doesnt work but choose existing files works

16 January 2012 at 5:37pm Last edited: 16 January 2012 5:43pm
Okay I removed " ?> " but no help.
Should I remove <?php and ?> from all .php files ?
When I upload the file, it uploads correctly but does not show in attached files.
Edit.
I checked my firebug & got this error in console.
NetworkError: 500 Internal Server Error - http://test.mydomain.com/admin/EditForm/field/GalleryImages/UploadifyForm/field/UploadedFiles/refresh?SecurityID=6e334a93b822455926009cbec9934a29167e7eb0&ctf[GalleryImages][start]=0&ctf[GalleryImages][per_page]=10&ctf[GalleryImages][showall]=0&ctf[GalleryImages][sort]=&ctf[GalleryImages][sort_dir]=&ctf[GalleryImages][search]=&ctf[GalleryImages][filter]=&ctf[GalleryImages][view]=grid&ctf[GalleryImages][imagesize]=100&FileIDs=%0D%0A%0D%0A43925
-
Re: New file upload doesnt work but choose existing files works

16 January 2012 at 5:43pm Last edited: 16 January 2012 5:44pm
You need to remove all instances of ?> from all php files, but you still need to have the <?php in each file. Like I said, make sure the <?php is on the very first line of each document.
There may be other white space issues that I don't know about too. Try removing empty lines and spaces from the end of files. I think I've also needed to add an empty second line to an empty _config.php file at one stage too. All of that is tedious and awkward, but that's how I've solved this problem in the past.
(I'd love to know if there's a better way to debug this...).
-
Re: New file upload doesnt work but choose existing files works

16 January 2012 at 5:46pm Last edited: 16 January 2012 5:47pm
I think its something else. I just checked my post response from Firebug and got this
ERROR [User Error]: Couldn't run query:
SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName"
FROM "File"
WHERE ("File"."ID" IN (\r\n\r\n43925))
ORDER BY "SortOrder" ASCYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\r\n\r\n43925)) ORDER BY "SortOrder" ASC' at line 1
IN GET /admin/EditForm/field/GalleryImages/UploadifyForm/field/UploadedFiles/refresh?SecurityID=6e334a93b822455926009cbec9934a29167e7eb0&ctf[GalleryImages][start]=0&ctf[GalleryImages][per_page]=10&ctf[GalleryImages][showall]=0&ctf[GalleryImages][sort]=&ctf[GalleryImages][sort_dir]=&ctf[GalleryImages][search]=&ctf[GalleryImages][filter]=&ctf[GalleryImages][view]=grid&ctf[GalleryImages][imagesize]=100&FileIDs=%0D%0A%0D%0A43925
Line 525 in /home/test/public_html/sapphire/core/model/MySQLDatabase.phpSource
======
516: }
517:
518: function databaseError($msg, $errorLevel = E_USER_ERROR) {
519: // try to extract and format query
520: if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
521: $formatter = new SQLFormatter();
522: $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
523: }
524:
* 525: user_error($msg, $errorLevel);
526: }
527:
528: /**
529: * Return a boolean type-formatted string
530: *
531: * @param array $values Contains a tokenised list of info about this data typeTrace
=====
<ul>user_error(Couldn't run query:
SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName"
FROM "File"
WHERE ("File"."ID" IN (\r\n\r\n43925))
ORDER BY "SortOrder" ASCYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\r\n\r\n43925)) ORDER BY "SortOrder" ASC' at line 1,256)
line 525 of MySQLDatabase.phpMySQLDatabase->databaseError(Couldn't run query: SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\r\n\r\n43925)) ORDER BY "SortOrder" ASC | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\r\n\r\n43925)) ORDER BY "SortOrder" ASC' at line 1,256)
line 123 of MySQLDatabase.phpMySQLDatabase->query(SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\r\n\r\n43925)) ORDER BY "SortOrder" ASC,256)
line 129 of DB.phpDB::query(SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\r\n\r\n43925)) ORDER BY "SortOrder" ASC,256)
line 404 of SQLQuery.phpSQLQuery->execute()
line 761 of File.phpFile->instance_get("File"."ID" IN (\r\n\r\n43925),,,,DataObjectSet)
line 2714 of DataObject.phpDataObject::get(File,"File"."ID" IN (\r\n\r\n43925))
line 161 of MultipleFileUploadField.phpMultipleFileUploadField->Files()
line 369 of ViewableData.phpViewableData->obj(Files,,,1,)
line 411 of ViewableData.phpViewableData->cachedCall(Files,)
line 424 of ViewableData.phpViewableData->hasValue(Files)
line 11 of .cache.uploadify.templates.Includes.AttachedFiles.ssinclude(/home/test/public_html/silverstripe-cache/.cache.uploadify.templates.Includes.AttachedFiles.ss)
line 429 of SSViewer.phpSSViewer->process(MultipleImageUploadField)
line 342 of ViewableData.phpViewableData->renderWith(AttachedFiles)
line 107 of MultipleFileUploadField.phpMultipleFileUploadField->refresh(SS_HTTPRequest)
line 143 of RequestHandler.phpRequestHandler->handleRequest(SS_HTTPRequest)
line 161 of RequestHandler.phpRequestHandler->handleRequest(SS_HTTPRequest)
line 161 of RequestHandler.phpRequestHandler->handleRequest(SS_HTTPRequest)
line 161 of RequestHandler.phpRequestHandler->handleRequest(SS_HTTPRequest)
line 161 of RequestHandler.phpRequestHandler->handleRequest(SS_HTTPRequest)
line 147 of Controller.phpController->handleRequest(SS_HTTPRequest)
line 282 of Director.phpDirector::handleRequest(SS_HTTPRequest,Session)
line 125 of Director.phpDirector::direct(/admin/EditForm/field/GalleryImages/UploadifyForm/field/UploadedFiles/refresh)
line 127 of main.php</ul>
| 677 Views | ||
|
Page:
1
|
Go to Top |



