简体   繁体   English

上传文件远程服务器

[英]Upload file distant server

I'm using Formidable Pro and I create a hook to get all the data after the submit (Don't want to pay the addon API). 我使用的是Formidable Pro,我创建了一个钩子以在提交后获取所有数据(不想支付插件API)。 I modify the action of the form to go to my PHP script after submitting. 提交后,我修改了表单的操作以转到我的PHP脚本。 I just have a problem now, the form is used also to send images and PDF files. 我现在有一个问题,该表格还用于发送图像和PDF文件。

I try to move the images and PDF files after the submitting, with move_uploaded_file but nothing works. 我尝试在提交后使用move_uploaded_file移动图像和PDF文件,但没有任何效果。 I display the infos of $_FILES and I have this infos : 我显示$ _FILES的信息,并且我有以下信息:

array(
        [name] => Array
            (
                [0] => compte_rendu_12-12-16.pdf
            )

        [type] => Array
            (
                [0] => application/pdf
            )

        [tmp_name] => Array
            (
                [0] => /tmp/phpHCenke
            )

        [error] => Array
            (
                [0] => 0
            )

        [size] => Array
            (
                [0] => 176072
            )

    )

Here is my PHP code : 这是我的PHP代码:

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['file70'][0]['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['file70'][0]['tmp_name'], $uploadfile)) {
    echo "Upload with success";
} else {
    echo "Upload error";
}

I always have the message "upload error". 我总是收到“上传错误”消息。

Any idea ? 任何想法 ?

The $FILES array should be referenced as $ FILES数组应引用为

$_FILES['file70']['name'][0]

when multiple files are being uploaded 当多个文件正在上传时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM