OsiViper Posted September 22, 2006 Share Posted September 22, 2006 Ok, i have looked all over the internet for something like this.I just want a simple file upload script that people can upload pictures to a folder on the website and once the file upload is complete, it will display a link to the uploaded file -- i would also like to have a size limit on files if possible.Does anyone know of a script that can do this? i have found alot of upload scripts, but they are all just overly complicated for what i need. Link to comment https://forums.phpfreaks.com/topic/21733-simple-file-upload-script/ Share on other sites More sharing options...
michaellunsford Posted September 23, 2006 Share Posted September 23, 2006 dusted this one off for you. Hope it works ;D[code=php:0]<?phpini_set("memory_limit","128M"); //can be reduced (I think) to limit files. Default is probably 20Mif ($_FILES['userfile']['name']) { $newfilename=str_replace(" ","_",$_FILES['userfile']['name']); //files with spaces come in as underscores -- fix move_uploaded_file($_FILES['userfile']['tmp_name'], realpath(".")."/" . $newfilename);// chmod(realpath(".")."/".$_FILES['userfile']['name'],0777); //may be necessary -- depends echo "The file <a href=\"".$newfilename."\">".$newfilename."</a> was received."); echo "<br>\n<a href=\"".$filea."\">Click Here</a> to send another file.";} else echo "Send a file.\n<form enctype=\"multipart/form-data\" method=\"post\"><input name=\"userfile\" type=\"file\"><input type=\"submit\">";?>[/code]a quick mod can also loop this for multiple file uploads...[code=php:0]do{ $newfilename=str_replace(" ","_",$_FILES[key($_FILES)]['name']); move_uploaded_file($_FILES[key($_FILES)]['tmp_name'], realpath(".")."/".$newfilename); echo "The file <a href=\"".$newfilename."\">".$newfilename."</a> was received.<br>");} while(next($_FILES));[/code] Link to comment https://forums.phpfreaks.com/topic/21733-simple-file-upload-script/#findComment-97031 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.