Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsupajirakit/01716c4f1457e84e296b47401df2564e to your computer and use it in GitHub Desktop.
Save wsupajirakit/01716c4f1457e84e296b47401df2564e to your computer and use it in GitHub Desktop.
<?php
session_start();
$ssmovielogin = $_SESSION["ssmovielogin"];
if(strcmp($ssmovielogin,"now") == 0){
}else{
header( "location: login" );
}
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(basename($_FILES["fileToUpload"]["name"]!="")){
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
$temp = explode(".", $_FILES["fileToUpload"]["name"]);
$newfilename = round(microtime(true)) . '.' . end($temp);
$target_file = "images/".$newfilename;
$xfilename = $newfilename;
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "images/".$newfilename);
$uploadOk = 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.".$imageFileType;
$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)) {
$xfilename = basename( $_FILES["fileToUpload"]["name"]);
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}else {
$xfilename = "1";
}
$name = $_POST['name'];
$type = $_POST['type'];
$cate = $_POST['cate'];
$url = $_POST['url'];
echo "<br>".$name."<br>".$score."<br>".$cate."<br>".$url."<br>".$xfilename;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "xxxxx",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"operation\"\r\n\r\ncreate\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"sessionName\"\r\n\r\n4983f8445b18fe2b04206\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"element\"\r\n\r\n{\n \"ignmediano\": \"\",\n
\"ignmedia_tks_title\": \"$name\",\n
\"ignmedia_tks_mediatype\": \"$type\",\n \"ignmedia_tks_category\": \"$cate\",\n
\"ignmedia_tks_url\": \"$url\",\n \"assigned_user_id\": \"19x1\",\n \"createdtime\": \"2017-12-26 00:24:14\",\n \"modifiedtime\": \"2018-06-05 20:02:24\",\n \"cf_ivtx_ulf_782\": \"$xfilename\",\n \"cf_802\": \"$xfilename\",\n \"id\": \"38x13\"\n }\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"elementType\"\r\n\r\nIgnmedia\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
"postman-token: 549963e3-53f6-c41a-a3ab-419ecce678a1"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
header('Location: tables.php');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment