PHP Datagrid AJAX File Upload

* The file upload is supported in Enterprise and Universal license.

File upload is one of the most requested features. And we are finally able to delivery this new feature. It requires only a SINGLE LINE of code, with only a single function call to set_col_fileupload(). Since PHP is installed as Apache module in our host server, the 3rd parameter is optional that the physical path is automatically mapped based on 2nd parameter, the base URL.

All the file operations (Update, Delete) are Ajax-based, without refreshing the page.

1
2
3
4
5
$dg = new C_DataGrid("SELECT * FROM shippers", "ShipperID", "shippers");
$dg -> set_col_fileupload("fileToUpload", '/phpGridx/photos/');
$dg -> enable_edit('FORM');
$dg->set_col_img("fileToUpload", "/phpGridx/photos/");
$dg -> display();

You should consider resizing images displayed so large images won’t blow your datagrid out of proportion. Read more about Image resize using CSS.

The below screenshot (click to enlarge) illustrates the file edit operations in edit form. It has the “delete” button to remove the existing file before uploading a new one. The file name is saved to table “shippers”.

The below screenshot (click to enlarge) shows uploading new file as part of creating a new record by click on “choose file”, then pick file “truck.jpg” from the local system. Then the file “truck.jpg” is saved to file system under “/phpGridx/foo/” folder, and the file name is stored in table “shippers” alone with rest of data.

The follow screen (click to enlarge) shows that new record has been successfully created and the file “truck.jpg” has been successfully uploaded.

No related content found.

Tags: