PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > can't figure out proper format for c:\ path for curl upload
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
can't figure out proper format for c:\ path for curl upload

Réponse
 
LinkBack Outils de la discussion
Vieux 05/01/2008, 04h18   #1
John Gunther
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut can't figure out proper format for c:\ path for curl upload

I can't figure out how to pass a c:\... filepath via curl for an RFC1867
multipart form upload in PHP 5.2.1.

I'm using the following code to perform a programmatic file upload to
the PHP server:

$filepath='/home/user/testfile.txt';
$ch=curl_init('http://bucksvsbytes.com/upload.php');
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'=>' @'.$filepath));
curl_exec($ch);
curl_close($ch);

Works great if the file I want to upload is on the web server but it
never is. The files I want are on the client computer, of course, e.g.
c:\home\user\testfile.txt

I've tried passing every variation of that path I can think of, e.g.:

C:\home\user\testfile.txt
C:\\home\\user\\testfile.txt
C:/home/user/testfile.txt
urlencode(...)
utf8_encode(...)

and nothing works. I either get the dreaded "failed creating formpost
data" or the filepath shows up in $_POST and $_FILES is empty. The
listed formats don't work with fopen() either.

I've searched dozens of web examples but I can't get it. !

For that matter, is there a better approach than curl for programmed
uploads of client computer files to the PHP server?
  Réponse avec citation
Vieux 05/01/2008, 04h43   #2
Manuel Lemos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: can't figure out proper format for c:\ path for curl upload

Hello,

on 01/05/2008 02:18 AM John Gunther said the following:
> I can't figure out how to pass a c:\... filepath via curl for an RFC1867
> multipart form upload in PHP 5.2.1.
>
> I'm using the following code to perform a programmatic file upload to
> the PHP server:
>
> $filepath='/home/user/testfile.txt';
> $ch=curl_init('http://bucksvsbytes.com/upload.php');
> curl_setopt($ch,CURLOPT_POST,true);
> curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
> curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'=>' @'.$filepath));
> curl_exec($ch);
> curl_close($ch);
>
> Works great if the file I want to upload is on the web server but it
> never is. The files I want are on the client computer, of course, e.g.
> c:\home\user\testfile.txt
>
> I've tried passing every variation of that path I can think of, e.g.:
>
> C:\home\user\testfile.txt
> C:\\home\\user\\testfile.txt
> C:/home/user/testfile.txt
> urlencode(...)
> utf8_encode(...)
>
> and nothing works. I either get the dreaded "failed creating formpost
> data" or the filepath shows up in $_POST and $_FILES is empty. The
> listed formats don't work with fopen() either.
>
> I've searched dozens of web examples but I can't get it. !
>
> For that matter, is there a better approach than curl for programmed
> uploads of client computer files to the PHP server?


When I use Curl I prefer composing a RAW HTTP request because I am sure
it will work as intended. Whenever possible I prefer using fsockopen
connections. In any case I use this HTTP client request class that wraps
everything and supports form submission with file upload as you need:

http://www.phpclasses.org/httpclient


--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h48.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09896 seconds with 10 queries