php上传图片到文件夹,php – jQuery / ajax上传图片并保存到文件夹

编程入门 行业动态 更新时间:2024-10-15 14:13:30

php<a href=https://www.elefans.com/category/jswz/34/1770945.html style=上传图片到文件夹,php – jQuery / ajax上传图片并保存到文件夹"/>

php上传图片到文件夹,php – jQuery / ajax上传图片并保存到文件夹

更新下面的代码

我找到了一些能够上传图像并显示其缩略图的代码.但是,我想将图像保存到特定文件夹中.

我可以用什么jQuery代码或ajax代码将原始图像保存到我选择的文件夹中?

这是完整的代码:

.input-file-row-1:after {

content: ".";

display: block;

clear: both;

visibility: hidden;

line-height: 0;

height: 0;

}

.input-file-row-1{

display: inline-block;

margin-top: 25px;

position: relative;

}

#preview_image {

display: none;

width: 90px;

height: 90px;

margin: 2px 0px 0px 5px;

border-radius: 10px;

}

.upload-file-container {

position: relative;

width: 100px;

height: 137px;

overflow: hidden;

background: url(.png) top center no-repeat;

float: left;

margin-left: 23px;

}

.upload-file-container-text{

font-family: Arial, sans-serif;

font-size: 12px;

color: #719d2b;

line-height: 17px;

text-align: center;

display: block;

position: absolute;

left: 0;

bottom: 0;

width: 100px;

height: 35px;

}

.upload-file-container-text > span{

border-bottom: 1px solid #719d2b;

cursor: pointer;

}

.one_opacity_0 {

opacity: 0;

height: 0;

width: 1px;

float: left;

}

$( document ).ready(function() {

function readURL(input, target) {

if (input.files && input.files[0]) {

var reader = new FileReader();

var image_target = $(target);

reader.onload = function (e) {

image_target.attr('src', e.target.result).show();

};

reader.readAsDataURL(input.files[0]);

}

}

$("#patient_pic").live("change",function(){

readURL(this, "#preview_image")

});

});

Add Photo

更新:我认为我走在正确的轨道上.我很接近,但我不知道从jQuery发送什么数据.我添加了一个php scrit,它的回调成功,但我没有发送正确的var.我想如果我发送正确的val我可以得到它.

码:

$( document ).ready(function() {

function readURL(input, target) {

if (input.files && input.files[0]) {

var reader = new FileReader();

var image_target = $(target);

reader.onload = function (e) {

image_target.attr('src', e.target.result).show();

$.ajax({

type:'POST',

url: 'theUpload.php',

data: input.files[0],

success:function(data){

console.log("success");

console.log(data);

alert(data);

},

error: function(data){

console.log("error");

console.log(data);

}

});

};

reader.readAsDataURL(input.files[0]);

}

}

$("#patient_pic").live("change",function(){

readURL(this, "#preview_image")

});

});

更多推荐

php上传图片到文件夹,php – jQuery / ajax上传图片并保存到文件夹

本文发布于:2024-02-27 10:45:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1706239.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上传图片   文件夹   并保存   php   ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!