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.

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

报告相同问题?

悬赏问题

  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码