Пример #1
0
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded.";
        $fileContent = file_get_contents($_FILES['fileToUpload']['tmp_name']);
        $filename = $_FILES['fileToUpload']['name'];
        $url = "http://www.sasankmacherla.com/uploads/" . "{$filename}";
        //insertimagedb($filename,$url,$user_check);
        //echo "$filename";
        //echo "$url";
        //echo "$user_check";
        insertimagedb($filename, $url, $user_check);
        //replicateimagedb($filename,$url,$user_check);
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
Пример #2
0
<?php

session_start();
include_once 'dbconnect.php';
include 'updateimagedb.php';
include 'curl_updateimagedb.php';
if (!isset($_SESSION['user'])) {
    header("Location: index.php");
}
$res = mysql_query("SELECT * FROM userinfo WHERE user_id=" . $_SESSION['user']);
$userRow = mysql_fetch_array($res);
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
    $jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
    $img = $_GET["img"];
    $filename = "uploads/img_" . mktime() . ".jpg";
    file_put_contents($filename, $jpg);
    //$fileContent = file_get_contents($img,$jpg);
    $file = "img_" . mktime() . ".jpg";
    $filestring = str_replace(' ', '%20', $file);
    $url = "http://www.sasankmacherla.com/uploads/" . "{$filestring}";
    insertimagedb($file, $url, $userRow['username']);
    replicateimagedb($file, $url, $userRow['username']);
} else {
    echo "Encoded JPEG information not received.";
}
?>


<?php

include 'updateimagedb.php';
$filename = $_POST['filename'];
$url = $_POST['filepath'];
$user = $_POST['user'];
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
$destination = "../uploads/" . "{$filename}";
$file = fopen($destination, "w+");
fputs($file, $data);
fclose($file);
echo "saved";
$filepath = "http://sasankmacherla.com/uploads/" . "{$filename}";
insertimagedb($filename, $filepath, $user);