Results 1 to 3 of 3
Thread: Uploading to my own form
-
03-09-2011, 06:27 PM #1Junior Guru Wannabe
- Join Date
- Dec 2010
- Posts
- 31
Uploading to my own form
This is my attempt to make an upload script to upload images to my own website.
Code:<?php $ch = curl_init("http://*******.com/imgupload.html"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array('file'=>"@/home/user/mypic.jpg", 'submit'=>'Submit')); $postResult = curl_exec($ch); curl_close($ch); print "$postResult"; ?>
Code:<html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>
-
03-10-2011, 05:53 AM #2Newbie
- Join Date
- Feb 2011
- Posts
- 8
Try this:
PHP Code:<?php
$ch = curl_init("http://*******.com/imgupload.html");
curl_setopt($ch, CURL_HTTPHEADER, "Content-type: multipart/form-data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
array('file'=>"@/home/user/mypic.jpg",
'submit'=>'Submit'));
$postResult = curl_exec($ch);
curl_close($ch);
var_dump($postResult);
?>
During development it's better to var_dump() variables as it might be a boolean value which print doesn't show. Of course if development is done, you can just go print it.
-
03-10-2011, 07:37 AM #3WHT Addict
- Join Date
- Jan 2010
- Location
- Sweden
- Posts
- 130
The script should go against upload_file.php, not imgupload.html
Please do the needful..
Similar Threads
-
[PHP] uploading a file from a web form
By Omega-Mark in forum Programming DiscussionReplies: 2Last Post: 04-06-2005, 12:06 PM -
Request: text form and image uploading script (PHP)
By I'd Hit It in forum Other Offers & RequestsReplies: 0Last Post: 03-18-2005, 07:48 PM -
[EzWebForm 1.5] Order Forms, Support Form, Contact Form with 10 Customizations for $8
By ezwebform in forum Other Offers & RequestsReplies: 0Last Post: 09-09-2003, 01:41 PM -
[EzWebForm 1.5] Order Forms, Support Form, Contact Form with 10 Customizations for $8
By ezwebform in forum Other Offers & RequestsReplies: 2Last Post: 08-30-2003, 05:06 PM -
Uploading files via a form
By Joshua44 in forum Programming DiscussionReplies: 6Last Post: 10-17-2002, 10:46 PM