Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-15-2010, 08:31 PM   #1
Registered: May 2006
Posts: 49

Rep: Reputation: 15
cURL php upload posting $_FILES[file][name] array creation

Hi All,

I'm uploading from https site to a remote https site.

I'm having trouble using method POST multipart/form-data as firefox sees this unencrypted post data and aborts the operation.

I was thinking of using curl (details below) but i get "undefined index : file in upload.php. (as these super(or automatic) globals arn't passed.

In the fetch1.php below, i'm attempting to post variables and recreate these globals on the new server.

I cannot get it to register the global variables

upload form -> fetch1.php(on same server) -> upload.php (remote ssl)

 // include_once('file://///Mainxp/shareddocs/psd.php');
header('Expires: Tue, 08 Oct 1991 00:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
// set to remote script to call

$remote = '';
$remote .= '?job_id=' . $_GET['job_id'];
$basename = basename($_FILES['file']['name']);
$remote .= '&basename=' . $basename;

$ch = curl_init();
//curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $remote);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/gd_bundle.crt");

then upload.php tries to extract post variables and create globals

 global($_FILES['file']['name']) =$_GET['basename'];

if($_FILES['file']['error'] == UPLOAD_ERR_OK){

$path = '/var/www/html/uploads/';							//destination upload directory

$path .= basename($_FILES['file']['name']);					//concats new path to base file name (pulled from $_files array
 if(move_uploaded_file($_FILES['file']['tmp_name'], $path)){
       //upload successful

any help would be greatly appreciated.. thanks
Old 04-16-2010, 04:57 AM   #2
Sergei Steshenko
Senior Member
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Originally Posted by devwink View Post
In the fetch1.php below, i'm attempting to post variables and recreate these globals on the new server.
I am not a PHP guy, but recreating global variables smells terribly fishy - regardless of language.
Old 04-16-2010, 07:19 AM   #3
Registered: May 2006
Posts: 49

Original Poster
Rep: Reputation: 15
thanks Sergei
I'm uploading images from my (commercial shared server) to my because commercial shared server doesn't have APC enabled and I want to getprogress , (that part is ajax and it works fine with curl )

I also want to resize and store large images and avoid bandwith/storage if all goes as planned.

I also hope to load share using ping to establish the home server loads.

May be I should write it to mysql and read it again at the other end, but i still have to pass one common variable to reference the upload.

I Want the progress bar to stay nested in the page my form is on one server and is passing url variables to another server (also https but different certificate)

My commercial shared server host will not put a shared ssl in the domain.(and still provide a seal).

I was thinking of dropping the seal as I intend to outsource the e-commerce bit.

It all works fine on I.E, but firefox is a bit more safe savy.


Last edited by devwink; 04-16-2010 at 07:25 AM. Reason: add


curl, global, php, ssl, upload, variables

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cURL not posting login data? Travesser Linux - General 1 02-15-2007 01:14 PM
php file upload lord-fu Programming 2 04-29-2006 11:03 PM
php upload an array of images spoody_goon Programming 3 05-22-2005 11:42 AM
File upload via PHP saravanan1979 Programming 1 02-14-2002 04:28 AM
File upload via PHP!!! saravanan1979 Programming 0 02-14-2002 01:55 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration