Jump to content

Archived

This topic is now archived and is closed to further replies.

OsiViper

Simple File Upload script

Recommended Posts

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.

Share this post


Link to post
Share on other sites
dusted this one off for you. Hope it works  ;D

[code=php:0]<?php
ini_set("memory_limit","128M"); //can be reduced (I think) to limit files. Default is probably 20M
if ($_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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.