-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd.php
41 lines (41 loc) · 864 Bytes
/
add.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
include "IPFS.php";
use Cloutier\PhpIpfsApi\IPFS;
error_reporting(0);
/*ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);*/
header('Access-Control-Allow-Origin: *');
header('Content-type: application/json');
if (count($_FILES)>0)
{
foreach($_FILES as $file)
{
if (move_uploaded_file($file["tmp_name"], "upload/".$file['name']))
{
$content=file_get_contents("upload/".$file['name']);
}
//echo $content;
$ipfs = new IPFS("127.0.0.1", "8080", "5001"); // leaving out the arguments will default to these values
$cid=$ipfs->add($content);
if ($cid)
{
$url="https://ipfs.nextwallet.org/ipfs/";
$o->success=true;
$o->url=$url;
$o->cid=$cid;
}
else
{
$o->success=false;
$o->message=$cid;
}
}
}
else
{
$o->success=false;
$o->message="Select file";
}
echo json_encode($o);
?>