This is a bit complicated, I'm just hoping someone else has run into this and knows how to do it a different way or make it work.
When sending a file as part of form information included in a cURL request, it appears you can not include a query string in the file name. Take a look at my example to see what I'm talking about.
Code: //This creates an example image with some text from $_GET['img'] you can try calling this directly to see what the output looks like
if(isset($_GET['img'])){
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 3, 3, 3, $_GET['img'], $text_color);
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
exit;
}
//Show what was sent to the $_POST and $_FILES variables
if(isset($_POST['showpost'])){
echo '<pre>';
print_r($_POST);
print_r($_FILES);
exit;
}
//Here's the part where we get in trouble...
//This works
//$imgURL = '@'.$_SERVER['SCRIPT_FILENAME'];
//This doesn't work
$imgURL = '@'.$_SERVER['SCRIPT_FILENAME'].'?img=true';
$data = array('showpost' => 'true', 'file' => $imgURL);
//Now do the cURL request to show information about the file that was sent
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
if(curl_errno($ch))
echo curl_error($ch);
curl_close($ch);
When using the section that says "This doesn't work" you'll get the cURL error "failed creating formpost data".
Any suggestions?
Need help adding a timestamp to my filename/variable
Hello, I'm kind of stupid when it comes to php and I need a tiny bit of help. I've got a form/php setup that allows a user to upload an image to my server. The upload is working well, and the code
PHP Directory Listing Not working
Hey Guys,I need help, I tried a ton of directory listing scripts and they all don't work. Althogh the normal Apache Directory Indexing does work when you visit. The URL is
Phase Error I can't seem to find :(`
Hey guys, I can seem to find my phase error on this. I am getting this error[error]Parse error: syntax error, unexpected $end in /home/klrbal/public_html/Mafia-test/tempfam.php on line
Significance of BPM
Hi Experts,
Gaining access to Drop Down Menu Variable
code is below, I am creating a drop down menu. I want to echo the value selected in the drop down menu in the php file that is executed afterwards. when I echo frmcounty in the php file it returns
highlighting search terms
well, I started this in the regular PHP section, but it no longer fits there. Suffice it to say, I'm trying to take individual search terms that are being $_POSTed and highlighting them in the search
how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a sessionCode: <?phpinclude_once 'Connect.php';if (!is_authed()) { die ('You are not
Default TimeZone
The server I'm working with is hosted in America so all times inserted into the database are coming out 5 hours differen't to what I want them to. I attempted placing the following in my Header
post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit button, when I set the type='image' it will not submit to itself. Can someone help me figure out
SAP FICO learning materials
Hi all,