light893 Posted February 6, 2007 Share Posted February 6, 2007 Hello, I've been banging my head on this for the past day. I have looked in the php docs and found the example below which I copied. I tried on 2 different servers and I get the error: "failed creating formpost data". So it seems to be erroring before the information is even sent via curl. I have the file "dog.txt" in the same directory as my php script initiating the send. There seems to be something that I am just missing and can't figure it out. Any advice would be appreciated. I have tried on my local machine using Apache and on my remote server using Windows IIS with the same error. [pre]<?php $postData = array(); $postData['uploaded'] = "@dog.txt"; $postData['submit'] = "UPLOAD"; $postData['max_file_size'] = "300000"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.mydomain.com/scripts/curlTest/upload.php" ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); } curl_close($ch); print "$postResult"; ?>[/pre] Quote Link to comment https://forums.phpfreaks.com/topic/37353-solved-curl-file-upload-failed-creating-formpost-data-error/ Share on other sites More sharing options...
light893 Posted February 13, 2007 Author Share Posted February 13, 2007 I was able to solve the problem in case it may help anyone else. I was referencing the location incorrectly. In the file sending, it should be: [pre]$file = "D:\htdocs\scripts\curlTest\send2.php"; $postData['uploaded'] = "@$file"; $postData['submit'] = "UPLOAD"; $postData['max_file_size'] = "300000";[/pre] and in the file receiving the call, it should be: [pre]$target = "upload\\"; $target = $target . basename( $_FILES['uploaded']['name']) ;[/pre] Quote Link to comment https://forums.phpfreaks.com/topic/37353-solved-curl-file-upload-failed-creating-formpost-data-error/#findComment-183657 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.