简体   繁体   English

从一个项目文件夹到另一个项目文件夹的卷曲文件上传不起作用

[英]Curl file upload from one project folder to another project folder is not working

I am trying to upload from one project folder to another project folder using CURL , but its not working . 我正在尝试使用CURL从一个项目文件夹上载到另一个项目文件夹,但是它不起作用。 Can anyone suggest me ? 有人可以建议我吗?

Below I am posting my codes 下面我发布我的代码

This code is in one project folder . 此代码在一个项目文件夹中。

<form enctype="multipart/form-data" encoding='multipart/form-data' method='post' action="form.php">
  <input name="uploadedfile" type="file" value="choose">
  <input type="submit" value="Upload">
</form>
<?
//echo "<pre>";print_r($_FILES['uploadedfile']);
if (isset($_FILES['uploadedfile']['name']) && $_FILES['uploadedfile']['name']!="") {
 $filename  = $_FILES['uploadedfile']['tmp_name'];
 $handle    = fopen($filename, "r");
 $data      = fread($handle, filesize($filename));
 $POST_DATA = array(
   'file' => base64_encode($data)
 );
 $curl = curl_init();
 curl_setopt($curl, CURLOPT_URL, 'http://localhost/curl_image_server/handle.php');
 curl_setopt($curl, CURLOPT_TIMEOUT, 30);
 curl_setopt($curl, CURLOPT_POST, 1);
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($curl, CURLOPT_POSTFIELDS, $POST_DATA);
 $response = curl_exec($curl);
 curl_close ($curl);
 echo "<h2>File Uploaded</h2>";
}
?>

This code is in another project folder 此代码在另一个项目文件夹中

<?php
echo $encoded_file = $_POST['file'];
$decoded_file = base64_decode($encoded_file);
/* Now you can copy the uploaded file to your server. */
file_put_contents('subins', $decoded_file);


?>

Well, you are calling exit() at the end of this line: 好吧,您在此行的结尾处调用exit()

echo $encoded_file = $_POST['file'];exit;

so the scripts end on this line, hence no file is saved. 因此脚本在此行结束,因此不会保存任何文件。

暂无
暂无

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

相关问题 如何将文件上传到另一个文件夹内的文件夹 - How to upload file to folder inside another folder 如何将图像从一个项目上传到另一个项目 - How to upload image from one project to another project laravel 为另一个项目文件夹设置安装在另一个项目文件夹中的作曲家 - setting up composer installed in another project folder for a new project folder 如何将文件从一个文件夹复制到另一个 - How to Copy the File from one Folder to another 在 php 中将文件从一个文件夹复制到另一个文件夹 - Copy a file from one folder to another in php 通过将路径作为参数传递给使用Dropbox API的PHP,将一个文件或文件夹从一个位置移动到另一个位置? - Move one file or folder from one location to another by passing path as a argument in PHP working with Dropbox API? 将项目从 xampp 文件夹更改为另一个文件夹并删除以前的 xampp 版本 - Changed project from xampp folder to another folder and deleted previous xampp version 我想从文件夹中获取图像并将图像上传到另一个没有任何输入类型文件的文件夹中? - i want to get images from folder and upload image into another folder without any input type file? 如何允许一个文件夹中的文件访问另一个文件夹中的文件? - How do I allow a file from one folder to access a file from another folder? Laravel,不会将文件上传到 Public_html,而是在 laravel 根项目中创建文件夹 - Laravel, Wont upload file to Public_html but instead creating folder in laravel root project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM