File upload

QuestionsFile upload
Roberto Ventosti asked 6 years ago

I have a problem with the file upload, once uploaded the file I do not know why but the file itself is deleted and is no longer available.

I attach the code for greater clarity.
<?php
/**
* PHP Grid Component
*
* @author Abu Ghufran <[email protected]> – http://www.phpgrid.org
* @version 2.0.0
* @license: see license.txt included in package
*/

// include db config
include_once(“../phpgrid/config.php”);
// include and create object
include(“../phpgrid/lib/inc/jqgrid_dist.php”);

// another detail grid.
$grid = new jqgrid($db_conf);
$opt = array();
$opt[“sortname”] = ‘id’; // by default sort grid by this field
$opt[“sortorder”] = “desc”; // ASC or DESC
$opt[“height”] = “100”;
$opt[“width”] = “50%”;
$opt[“caption”] = “Doc”; // caption of grid
$grid->set_options($opt);
$grid->set_actions(array(
“add”=>true, // allow/disallow add
“edit”=>true, // allow/disallow edit
“delete”=>true, // allow/disallow delete
“rowactions”=>true, // show/hide row wise edit/del/save option
“autofilter” => true, // show/hide autofilter for search
“search” => “advance” // show single/multi field search condition (e.g. simple or advance)
)
);

$grid->select_command = “SELECT * FROM Doc WHERE id_sopralluogo = $_GET[id_sopralluogo]”;
// this db table will be used for add,edit,delete
$grid->table = “Doc”;

$col = array();
$col[“title”] = “Id”; // caption of column
$col[“name”] = “id”;
$col[“width”] = “100”;
$cols[] = $col;

$col = array();
$col[“title”] = “Id sopralluogo”;
$col[“name”] = “id_sopralluogo”;
//$col[“dbname”] = “clients.name”; // this is required as we need to search in name field, not id
$col[“width”] = “100”;
$col[“align”] = “left”;
$col[“editable”] = true;
//$col[“edittype”] = “select”; // render as select
//$str = $g->get_dropdown_values(“select distinct client_id as k, name as v from clients”);
//$col[“editoptions”] = array(“value”=>$str);
$cols[] = $col;
$col = array();
$col[“title”] = “Note”;
$col[“name”] = “file”;
$col[“width”] = “50”;
$col[“editable”] = true;
$col[“edittype”] = “file”; // render as file
$col[“upload_dir”] = “Foto”; // upload here
$col[“show”] = array(“list”=>false,”edit”=>true,”add”=>true); // only show in add/edit dialog
$col[“editrules”] = array(“ifexist”=>”override”);
$cols[] = $col;
$col = array();
$col[“title”] = “Image”;
$col[“name”] = “logo”;
$col[“width”] = “200”;
$col[“editable”] = true;
$col[“default”] = “<a href='{file}’ target=’_blank’><img height=100 src='{file}’></a>”;
$col[“show”] = array(“list”=>true,”edit”=>false,”add”=>false); // only show in listing
$cols[] = $col;
$grid->set_columns($cols);
$sopralluogo[“on_insert”] = array(“add_sopralluogo”, null, true);
$grid->set_events($sopralluogo);
function add_sopralluogo(&$data)
{
$id = intval($_GET[“id_sopralluogo”]);
$data[“params”][“id_sopralluogo”] = $id;
}
// generate grid output, with unique grid name as ‘list1’
$out_list3 = $grid->render(“list3”);
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”&gt;
<html>
<head>
<link rel=”stylesheet” type=”text/css” media=”screen” href=”../phpgrid/lib/js/themes/redmond/jquery-ui.custom.css”></link>
<link rel=”stylesheet” type=”text/css” media=”screen” href=”../phpgrid/lib/js/jqgrid/css/ui.jqgrid.css”></link>

<script src=”../phpgrid/lib/js/jquery.min.js” type=”text/javascript”></script>
<script src=”../phpgrid/lib/js/jqgrid/js/i18n/grid.locale-en.js” type=”text/javascript”></script>
<script src=”../phpgrid/lib/js/jqgrid/js/jquery.jqGrid.min.js” type=”text/javascript”></script>
<script src=”../phpgrid/lib/js/themes/jquery-ui.custom.min.js” type=”text/javascript”></script>
</head>
<body>
<script>
// open dialog for editing
var opts = {
‘ondblClickRow’: function (id) {
jQuery(this).jqGrid(‘editGridRow’, id, <?php echo json_encode_jsfunc($g->options[“edit_options”])?>);
}
};
</script>

<div>
<?php echo $out_list3?>
</div>

</div>
</body>
</html>

 

5 Answers
Abu Ghufran Staff answered 6 years ago

Hi,
Perhaps, file may not be uploaded due to permission on ‘Foto’ folder OR folder may not exist in folder where your code file exist.
You can check php error log file for exact reason. There is nothing in your code and lib code to auto-delete files.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Ro replied 6 years ago

il file viene scritto nella cartella Foto che ha permessi 777 quando faccio la selezione per l’upload ma dando il submit il file scompare.

Speravo di avere sbagliato qualcosa ma così non so proprio che fare.

Grazie per la sollecita risposta

roberto ventosti answered 6 years ago

Sorry if I insist but I’m literally going crazy I rewrote the code but the behavior is the same, when the file is selected the file itself is written in the correct destination folder but as soon as you press submit the file disappears. I really do not know what to do I tried them all. Please help me. Thank you Roberto Ventosti

Abu Ghufran Staff answered 6 years ago

You can email me code + database dump at [email protected] and i’ll update you back.
 

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Tim Moore answered 5 years ago

Has this issue ever resolved? I am getting the same results even using the demo (file-upload-blob.php).

Abu Ghufran Staff answered 5 years ago

I rechecked this ticket, we were unable to regenerate this issue and was working as expected.
You can email me screencast (via jing.com etc) showing the issue. Email me at [email protected]

If you are testing locally, try after disabling anti-virus.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

0 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?