dongqing6661 2018-11-08 13:02
浏览 254
已采纳

临时文件不会出现在xampp / tmp中

I'm uploading a csv file to my php server with this form:

<form action="importCSV.php" method="post" enctype="multipart/form-data">
            <br>Select file: <input type="file" name="file">
            <br><input type="submit" name="import" value="Import file">
</form>

And what I want to do with that file is to add its content to a table in my mysql server.

$url=$_FILES['file']['tmp_name'];
$con = new mysqli(HOST, US, PW, BBDD);
$sql="load data local infile '" . $url. " into table users fields terminated by ':'";
$con->query($sql);
$con->close();

The problem is that in the "tmp" folder of the php server doesn't appear the csv file, but in this line $url=$_FILES['file']['tmp_name'] $url has a real url with a tmp_name. I don't understand what's happening there: I have the url with the tmp_name of the file but it actually doesn't exists?

I have checked the php.ini file and this are the values for the file uploads:

file_uploads=On
upload_tmp_dir="C:\xampp\tmp"
upload_max_filesize=2M
max_file_uploads=20

I'm not worried about the "upload_max_filesize", the file I'm trying to upload has a size of only 56 bytes.

Please, any ideas?

  • 写回答

1条回答 默认 最新

  • dongtao6842 2018-11-08 13:19
    关注

    I can't believe this... It seems that the mysql server doesn't understand this character \. It's only a problem of compatibility between operative systems.

    The solution is only to replace the character: $url= str_replace("\\", "/", $url).

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

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案