Monday 15 April 2013

Ajax to php - directory is mising -


I just need the eyes of a fresh couple and this is something silly, but I have this problem:

I changed the name of the inline folder such as:

  $ (function () {$ (".name"). Dblclick (function (e) {e.stopPropagation ( ); Var currentEle = $ (this). Child ("a"); var value = current Ele.html (); update val (current idle, value);});}); Function updateVal (current id, value) {var is_file = 0; If (currentEle.hasClass ('file')) {is_file = 1; } Var rnm_dir = currentEle.attr ('href'); Rnm_dir = rnm_dir.replace ('? Dir =', ''); $ (Current id) .html ('& lt; input class = "thwl" type = "text" value = "' + value + '" />);); . $ (". ThVal") focus (); $ (". ThVal"). Key (function (event) {if (event.keyCode == 13) {var n_name = $ (". ThVal"). Val (); $ ('. ThVal'). Remove (); $ (currentEle) .html (N_name); $ .ajax ({cache: false, type: 'fetching' url: 'addfunctions.php', data: {'rnm_dir': rnm_dir, 'is_file': is_file, 'new_name': n_name, Function ':' rename '}, data type: "json", first send: function () {console.log (' ok ');}, success: function (response) {warning (response.name);}, error : Function (request, status, error) {warning (request.responseText);}}})}}); $ (Document). Click (function () {$ (current id) .html ($ (". ThVal"). Val ());}); }   

In the console I see:

  rnm_dir =% 3Fdir% 3Dpress / Blackfield / Blackfield% 25202 / joijuoi & amp; Is_file = 0 & amp; NEW_NAME = dcxfgdfxg & amp; = Function = rename   

but I get an error that the rename (, / dcxfgdfxg)

is missing in the root directory, but if I run the console directly to file the output:

  addfunctions.php rnm_dir =% 3Fdir% 3Dpress / Blackfield / Blackfield% 25202 / new% 2520Folder & amp; Is_file = 0 & amp; NEW_NAME = joijuoi & amp; Function = Rename   

This actually changes its name

My PHP is:

  $ is_file = $ _GET [' Is_file ']; $ Rnm_dir = urldecode ($ _ GET ['rnm_dir']); $ New_name = $ _GET ['new_name']; $ Rnm_dir = str_replace ('? Dir =', '', $ rnm_dir); If ($ is_file) {$ inf = pathinfo ($ rnm_dir); $ Ext = $ inf ['Extension']; $ Dir = $ inf ['dirname']; $ N_file = $ dir '/'. $ New_name '.' $ Ext. Rename ($ rnm_dir, $ n_file); $ '[' Name '] = $ n_file; Eco json_encode ($ out); } And {$ dir = dirname ($ rnm_dir); $ N_dir = $ dir '/'. $ New_name; Rename ($ rnm_dir, $ n_dir); $ '[Name'] = $ n_dir; Eco json_encode ($ out); }   

amendment to work code

believe me Is the issue ? Due to rnm_dir in place of GET key ? Rnm_dir . When the data passes in such a way, then ? is not required.

A quick way to open it in the future is using the PHP function print_r ($ _GET); To see the actual data collected on the server side.

No comments:

Post a Comment