Drezard Posted September 14, 2006 Share Posted September 14, 2006 Hello, How do i create a script that uploads a file to the webserver. But I only want files smaller then 1mb and Jpgs and Pngs. How do i do this?- cheers, Daniel Quote Link to comment Share on other sites More sharing options...
geoffl1 Posted September 14, 2006 Share Posted September 14, 2006 use an html file for the upload form and have it post to a php... you can find tons of them around the internet if you look. Quote Link to comment Share on other sites More sharing options...
laide234 Posted September 14, 2006 Share Posted September 14, 2006 This might be of some help...http://www.nstoia.com/toh/technical/imageresize/index.php Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 There's a tutorial for one here at [url=http://www.phpfreaks.com/tutorials/85/6.php]PHP Freaks[/url].It says it's for beginners, and it looks as though it has lots of advanced features.RegardsHuggie Quote Link to comment Share on other sites More sharing options...
rajeshrhino Posted September 14, 2006 Share Posted September 14, 2006 Your HTML page :-----------------<form name='file_upload' method='POST' action='Upload.php' enctype='multipart/form-data'><input type='file' name='file'><input type='submit' name='Upload' value='Upload'></form>Upload.php-----------<?phpif($_POST['Upload']) { if(isset($_FILES[file][tmp_name]) && $_FILES[file][error]=='0') { if($_FILES[file][type]=='image/pjpeg' || $_FILES[file][type]=='image/x-png') { if($_FILES[file][size]<'1048576') { $src = $_FILES[file][tmp_name]; $des = $_FILES[file][name]; if(!move_uploaded_file($src,$des)) { if(!copy($src,$des)) { echo "Unable To Upload File!"; } } } else { echo "Upload Images less than 1 Mb size only"; } } else { echo "Can Upload only JPG & PNG Images"; } }}?> 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.