I am supposed to upload images using using Ctrl keys for which I am using Ajax, but the problem is that while uploading the image names in the database successfully I am not able to upload them in the folder under the name images
I have the following code which is able to upload my images using ajax on database but unable to upload images in the folder
<script>
function showChar(e){
if(e.ctrlKey && e.charCode == 98){
e.preventDefault();
var j = $('#fl').click();
if(j){saveImage();}
}
}
function saveImage(){
//var abc = $('#form1').serialize();
//alert(abc);return false;
var fl = $('#fl').val();
if(fl != ''){
alert('t');
$.ajax({
type: 'post',
url: 'sent.php',
data: 'fl='+fl,
success:function(msg){
}
});
//$.ajaxFileUpload();
}
}
</script>
</head>
<body onkeypress="showChar(event);">
<form enctype="multipart/form-data" method="post" id="form1">
<input type="file" name="fl" id="fl" value=""/>
<input type="button" name="submit" id="submit" value="Submit" onclick="saveImage();"/>
</form>
and the query as
$fl = $_REQUEST['fl'];
$name = $_FILES['fl']['name'];
$temp = $_FILES['fl']['tmp_name'];
move_uploaded_file($temp, 'images/'.$fl);
$query = "INSERT INTO tbl_browse (fld_name) VALUES ('$fl')";
$res = mysql_query($query);
if(mysql_num_rows($res)>0){ return 'U'; }
Try this method
https://stackoverflow.com/a/24839628/1640577 check question and answer
$.ajax({
type: 'post',
url: 'sent.php',
data: 'fl='+fl,
processData: false,
contentType: false ,
success:function(msg){
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.