Jump to content

image upload


BrainSmasher

Recommended Posts

You may of cource addjust the stylesheet :)

<?php//#$#$ Settings that must be set$pass_default = "FL_l!v3s"; #the password in the formfield, must be specified$targetfolder = "./myuploads"; #upload targetfolder, compared to the current folder (./)$filetypes = array( #allowed MIME types (important!) "avi"=> "video/x-msvideo", #AVI files allowed "wmv"=> "video/x-ms-wmv", #WMV files allowed "gif"=> "image/gif"); #leave GIF type, for easy testing$max_bytes = "30000"; #maximum allowed filesize in bytes//#$#$ Optional settings$titlebar = "iUpload - Prof-Creations"; #text in the titlebar$fieldset = "Upload an image"; #text in the fieldset legend$password = ""; #spam preventing. filling this in enables password protect (optional)$error_pass = "Access denied."; #message warning on wrong password (if enabled)$error_upload = "File not recieved!";$error_type = "Wrong filetype!";$error_size = "The file is too large.";$error_chmod = "Couldn't set permissions!";$error_server = "Uploading failed:";$error_move = "Couldn't move file!"; #if this error occurs, the targetfolder may be buggy$no_error = "Uploading was successful! Click here:"; #after successful upload, this text will show up with a link to the file$upload_button = "Upload!";$upload_name = "Image";//#$#$ After this line no edit please!$filetypes = "(".implode("|",$filetypes).")";$password = ($password == "") ?$pass_default :$password;echo "<!DOCTYPE html PUBLIC ", "\"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">", "\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">", "\r\n<head>\r\n<title>$titlebar</title>", "\r\n\r\n<!-- Characterset -->\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />", "\r\n\r\n<!-- Stylesheet -->", "\r\n<style>\r\n.text { border:inset 2px #c0c0c0;", "\r\n background-color:#ffffff;", "\r\n font-size:12px;", "\r\n width:320px; padding:2px 0 1px;", "\r\n text-align:left; color:#000080; }", "\r\n.button { cursor:pointer;", "\r\n border:outset 2px #008000;", "\r\n background-color:#99ffcc;", "\r\n font-size:12px;", "\r\n width:70px; padding:0;", "\r\n text-align:center; color:#000000; }\r\n</style>", "\r\n<base target=\"_blank\" />\r\n</head>\r\n\r\n<body>";if (empty($_FILES['userfile']) == true){ echo "\r\n<form enctype=\"multipart/form-data\" action=\"{$_SERVER['PHP_SELF']}\" method=\"post\" target=\"_self\">", "\r\n<fieldset style=\"width:400px; text-align:center\"><legend>$fieldset</legend>", ($password != $pass_default) ?("\r\Password: <input type=\"password\" class=\"text\" name=\"password\" style=\"width:200px\"" . "\r\n onfocus='if (this.value==this.defaultValue) this.value=\"\"' value=\"{$pass_default}\" /><br />") :"\r\n<input type=\"hidden\" name=\"password\" value=\"{$pass_default}\" />", "\r\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$max_bytes}\" />", "\r\n<input type=\"file\" class=\"text\" name=\"userfile\" /><hr />", "\r\n<button type=\"submit\" class=\"button\">{$upload_button}</button>", "\r\n</fieldset></form>";}elseif (!ereg("^{$password}$",$_POST['password'])) { echo $error_pass; }elseif (is_uploaded_file($_FILES['userfile']['tmp_name']) == false) { echo $error_upload; }elseif (!ereg("^{$filetypes}$",$_FILES['userfile']['type'])) { echo $error_type; }elseif ($_FILES['userfile']['size'] > $max_bytes) { echo $error_size; }elseif ($_FILES['userfile']['error'] != 0) { echo "Error: ".$_FILES['userfile']['error']; }else{ if (move_uploaded_file($_FILES['userfile']['tmp_name'], "{$targetfolder}/{$_FILES['userfile']['name']}")) { if (!chmod("{$targetfolder}/{$_FILES['userfile']['name']}",0644)) { echo $error_chmod; } else { echo "{$no_error} <a href=\"{$targetfolder}/{$_FILES['userfile']['name']}\">{$upload_name}</a>"; } } else { echo "{$error_server} {$_FILES['userfile']['name']}<br />\r\n"; if (file_exists("{$targetfolder}/{$_FILES['userfile']['name']}") == false) { echo $error_move; } else { print_r($_FILES); } }}echo "\r\n</body>\r\n</html>";?>
I hope this is what you were looking for :)Any questions I will happily answer, some settings may be confusing or difficult to understand. I wrote this script myself with the help of some people, but in Dutch, and with the translations, I may have forgotton some tiny things, please remind me if so. This was meant for movie uploads, as noticable with the filetypes that are already there. But you may delete the movie filetypes, and add some image types, but please notice these MIME types are very important to work. Edited by Dan The Prof
Link to comment
Share on other sites

You may of cource addjust the stylesheet :)I hope this is what you were looking for :)Any questions I will happily answer, some settings may be confusing or difficult to understand. I wrote this script myself with the help of some people, but in Dutch, and with the translations, I may have forgotton some tiny things, please remind me if so. This was meant for movie uploads, as noticable with the filetypes that are already there. But you may delete the movie filetypes, and add some image types, but please notice these MIME types are very important to work.
Bedankt he, ( ben ook nl)Tnx, ill try it out
Link to comment
Share on other sites

Okay, cool :) Another language mate over here :)Do you want the Dutch version? All those comments might be easier to understand it they were Dutch? :)[*Edit:]What exactly do you want to do with this script? As you PMed me that you prefered the file upload via an URL query which is not possible according to myself?

Link to comment
Share on other sites

Okay, cool :) Another language mate over here :)Do you want the Dutch version? All those comments might be easier to understand it they were Dutch? :)[*Edit:]What exactly do you want to do with this script? As you PMed me that you prefered the file upload via an URL query which is not possible according to myself?
i want to combine it with visual basic to post the url in an inet control to execute the script
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...