无法在Winform中将BMP映像保存到localhost

时间:2014-04-24 20:49:46

标签: c# php upload localhost bmp

如果我使用jpg图像但不使用bmp图像,我的代码工作正常。 它显示文件不可写。 这是我的C#代码:

string fileName = @"E:\ProjectPics\new.BMP";
if (fileName != "")
{
     string path = "http://localhost/Images/upload.php";
     WebClient client = new WebClient();
     byte[] responseBinary = client.UploadFile(path, fileName);
     string response = Encoding.UTF8.GetString(responseBinary);
}

这是我的php代码:

<?php
//check whether the folder the exists
if(!(file_exists('upload')))
{
  //create the folder
  mkdir('upload');
  //give permission to the folder
  chmod('upload/', 0777);
}

$uploads_dir = './upload'; //Directory to save the file that comes from client application.
if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) {
    $tmp_name = $_FILES["file"]["tmp_name"];
    $name = $_FILES["file"]["name"];
    move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
else 

    {
       die("Upload failed with error " . $_FILES['file']['error']);
    }
?>

0 个答案:

没有答案
相关问题