upload photo
upload photo
Friends, please, help! my brain is broken!!!
I have two tables . Table 1 (emploee) - id, name, photo. Table 2 (photo) - id, photo.
Both tables are empty. I can not upload a photo to display it in table 1.
when I load a picture , an error - Unknown upload field name submitted.
Then A system error has occurred (More information).
What am i doing wrong?
<?php
/*
* Editor server script for DB table staffsubdepartment
* Created by http://editor.datatables.net/generator
*/
// DataTables PHP library and database connection
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
Editor::inst( $db, 'emploee')
->field(
Field::inst( 'name' ),
Field::inst( 'photo' )
)
->process( $_POST )
->json();
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
ajax: "php/emploee.php",
table: "#emploee",
fields: [ {
label: "Info:",
name: "info",
type: "upload"
}
]
} );
$('#emploee').DataTable( {
dom: "Tfrtip",
ajax: "php/emploee.php",
columns: [
{ data: "name" },
{ data: "title" },
{ data: "photo.photo",
defaultContent: "No image",
render: function ( d ) {
return d.webPath ?
'<img src="'+d.webPath+'"/>' :
null;
}
},
],
tableTools: {
sRowSelect: "os",
aButtons: [
{ sExtends: "editor_create", editor: editor },
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor }
]
}
} );
} );
Maksim
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Your javascript should be:
Your server side page should be:
The editor puts the photo.id id into the employee photo column in your database. You also have to give the javascript a type of upload to tell it that it is supposed to be an upload field.
Modgility,thanks for the answer!
But,I get an error:
SQLSTATE[42000]: Syntax error or access violation: 1064 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 'FROM
photo
WHEREphoto
.id
= '0'' at line 1thanks again!
Спасибо еще раз!
That looks a LOT better. Unfortunately, without a test page that I can view, my helping skills end here. If you have a test page let me know and I'll take a look at it for you. At least you're really close now!
Modgility,I solved the problem with an error.
written on one site - from is a keyword in SQL. You may not used it as a column name without quoting it. In MySQL, things like column names are quoted using backticks, ie
from
.but I also can not link the two tables . Table which should contain information about the photo (path , file extension ) remains empty.because this communication not working preview photos
ever written - "No image"