LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-15-2010, 09:31 PM   #1
devwink
Member
 
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)

fetch1.php
Code:
<?php 
 // 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 = 'https://example.com.au/upload.php';
$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_VERIFYPEER,TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/gd_bundle.crt");
curl_exec($ch);
curl_close($ch);
?>

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


Code:
<?php
 
 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, 05:57 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
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, 08:19 AM   #3
devwink
Member
 
Registered: May 2006
Posts: 49

Original Poster
Rep: Reputation: 15
thanks Sergei
I'm uploading images from my https://www.example.com.au (commercial shared server) to my https://example.net.au 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.

Cheers

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


Reply

Tags
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 02:14 PM
php file upload lord-fu Programming 2 04-30-2006 12:03 AM
php upload an array of images spoody_goon Programming 3 05-22-2005 12:42 PM
File upload via PHP saravanan1979 Programming 1 02-14-2002 05:28 AM
File upload via PHP!!! saravanan1979 Programming 0 02-14-2002 02:55 AM


All times are GMT -5. The time now is 06:59 PM.

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