This question already has an answer here:
这个问题在这里已有答案:
- Using HTML5 file uploads with AJAX and jQuery 2 answers
使用带有AJAX和jQuery 2答案的HTML5文件上传
I'm building an application that have to add a row in a MyPHP database with some data, included for each row an always different, small JPEG image. At the moment it is structured like this:
我正在构建一个应用程序,它必须在MyPHP数据库中添加一行数据,每行包含一个总是不同的小JPEG图像。目前它的结构如下:
JavaScript
function fn_addrow() {
document.write('<form action="ADVBKMNGR-EventClass_MANAGE.php?Mode=ADD" method="POST" enctype="multipart/form-data">')
document.write('<table width="500"><th width="150"></th><th width="350"></th>')
document.write('<TR>')
// Form building
document.write('<input type="submit" value="Ok proceed">')
document.write('</form>')
}
PHP
elseif($WorkMode == 'ADD'):
$ID_ev = $_POST[ID_evcls];
$ID_ds = $_POST[Desc];
// Write all the data in a new row
$query='INSERT INTO '.$db_tabscelta.' (`Cod_App`, `ID_eventclass`, `Descrizione`, `Active`, `Logo_Eve`) VALUES ("'.$Station_ID.'","'.strtoupper($ID_ev).'","'.$ID_ds.'","1","'.mysql_real_escape_string($datimmagine).'")';
$result = mysql_db_query("AdVisual_02_", $query ,$connessione);
unlink($ID_logo);
imagedestroy($ID_logo);
The call at the PHP side works, the record is added, but my problem is that at the end I remain on the PHP page, while I would like to return to the calling page and redisplay the whole table. And, the address of the PHP is displayed in the user screen, and I would NOT like this at all.
在PHP端的调用工作,添加了记录,但我的问题是,最后我仍然在PHP页面上,而我想返回到调用页面并重新显示整个表。并且,PHP的地址显示在用户屏幕中,我根本不喜欢这个。
Does anybody have suggestions?
有人有建议吗?
Very important: I've tried the way with the XMLHttpRequest()
command. It's fine, but I'm not able to upload the image at all.
非常重要:我已经尝试过使用XMLHttpRequest()命令。没关系,但我根本无法上传图片。
2 个解决方案
#1
0
Store the value of
存储值
$_SERVER['HTTP_REFERER']
Once you land on page. This will give you the URL
一旦你登陆页面。这将为您提供URL
After finishing the job redirect to this URL
完成作业重定向到此URL后
#2
0
I think this for what you searching for form that submits through ajax even file upload is present
我认为这是你搜索通过ajax甚至文件上传提交的表单的内容
#1
0
Store the value of
存储值
$_SERVER['HTTP_REFERER']
Once you land on page. This will give you the URL
一旦你登陆页面。这将为您提供URL
After finishing the job redirect to this URL
完成作业重定向到此URL后
#2
0
I think this for what you searching for form that submits through ajax even file upload is present
我认为这是你搜索通过ajax甚至文件上传提交的表单的内容