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 Link to comment https://forums.phpfreaks.com/topic/172340-solved-file-upload-via-php/ 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/172340-solved-file-upload-via-php/#findComment-908757 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.