dongzhang1987 2013-11-19 08:12
浏览 173
已采纳

Ajax图像上传 - 获取tmpname

Iam trying to create Ajax-Image Upload. Inorder to move image using move_uploaded_file() i need the name and tmp_name. Is there any functions in javascript to get the filename and temporary file name like the following on php.

$n=$_FILES["filefield"]["name"];
$t=$_FILES["filefield"]["tmp_name"];

I have the image name on the variable $newTidImg[1]. Can i assign like following

$n=$_FILES[$newTidImg[1]]["name"];
$t=$_FILES[$newTidImg[1]]["tmp_name"];

The following function used for ajax post which passes id and image name to changeImageAjx.php

function ajximgupls(trid,imgnam)

var tridImgval = trid+','+imgnam;
jQuery.ajax({
type: 'POST',
url: 'changeImageAjx.php',
data: 'urlTidimgs='+ tridImgval,
cache: false,
success: function(ret)

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dsbckxk165039 2013-11-19 08:31
    关注

    You cannot handle the image from javascript. but you can send the image back to javascript from php. $_FILES["filefield"]["tmp_name"] is the temp path of the file its a local file uri. you cannot do anything using javascript.

    you can use move_uploaded_file($_FILES["filefield"]["tmp_name"],"local file path");

    only from php side not from javascript.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)