php image upload -works在远程,但不是本地服务器

时间:2014-02-22 10:03:20

标签: php image forms upload

使用非常简单的脚本上传图片。 它在我的远程服务器上工作正常。 但是,在我的本地服务器上,上传的图像大小为0kb。 我检查了php.ini文件:

post_max_size = 40M
upload_max_filesize = 5M
file_uploads = On
upload_tmp_dir = /Applications/MAMP/tmp/php

所有这些文件都为每个人设置了读/写权限。

文件test.php包含以下格式:

<form action="test2.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

这会调用'test2.php'文件

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$allow = array("jpg", "jpeg", "gif", "png", "JPG", "JPEG", "GIF", "PNG");
$todir = 'uploads/';
if (!!$_FILES['file']['tmp_name'] ){ // is the file uploaded yet?
    $info = explode('.', strtolower( $_FILES['file']['name']) );
    if ( in_array( end($info), $allow)){ // is this file allowed
       if ( move_uploaded_file( $_FILES['file']['tmp_name'], $todir . $_FILES['file']['name'])){
    move_uploaded_file( $_FILES['file']['tmp_name'], $todir . $_FILES['file']['name']);
            // the file has been moved correctly
        }else{
            // error this file ext is not allowed
        }
    }
}
?>

没有错误返回请帮我拉出头发!!!

0 个答案:

没有答案