Jump to content

Simple File Upload script


OsiViper

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.
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.