DrTrans Posted August 28, 2009 Share Posted August 28, 2009 Does anyone have a basic file upload script.. im trying to figure out how to code it.. and im completly lost. I know that i need to setup a form.. and i need to store the filename in a database. so I can call the files later. Any general help on how to parse the upload would be great. Thanks Quote Link to comment Share on other sites More sharing options...
php_joe Posted August 29, 2009 Share Posted August 29, 2009 Does anyone have a basic file upload script.. im trying to figure out how to code it.. and im completly lost. I know that i need to setup a form.. and i need to store the filename in a database. so I can call the files later. Any general help on how to parse the upload would be great. Thanks <?php // // This sample shows how to fill in and submit data to a form that looks like: // // <form enctype="multipart/form-data" // action="somewhere.cgi" method="post"> // <input type="file" name="sampfile"> // <input type="text" name="filename"> // <input type="text" name="shoesize"> // <input type="submit" value="upload"> // </form> // // Pay attention to: // #1 - the input field names (name=) // #2 - the input field type so that you pass the upload file to the right // name // #3 - what URL to send the POST to. The action= attribute sets it. // // Author: Daniel Stenberg $uploadfile="/tmp/mydog.jpg"; $ch = curl_init("http://formsite.com/somewhere.cgi"); curl_setopt($ch, CURLOPT_POSTFIELDS, array('sampfile'=>"@$uploadfile", 'shoesize'=>'9', 'filename'=>"fake name for file")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); curl_close($ch); print "$postResult"; } ?> Quote Link to comment 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.