PHP Upload

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Greenie

New Member
Impact
0
Can somebody write a quick php script for me that uploads files, much like imageshack does (renames the files to avoid collisions) and stores them on the server. Thanks alot..

P.S Nothing complex is required :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Form.php:

<FORM NAME="uploadfile" METHOD="post" ACTION="upload.php" enctype="multipart/form-data">
File: <INPUT TYPE="file" NAME="file"> <INPUT TYPE="submit" NAME="submit" VALUE="Upload">
</FORM>

Upload.php:

<?
if (isset($submit)) {
foreach ($_FILES as $file) {
if (move_uploaded_file($file['tmp_name'], "/path/to/upload/dir/".$file['name'])) {
echo "File Uploaded!";
}
else
{
echo "File Upload Failed";
}
}
}
?>

Note: I just threw this together in about 30 seconds. Just an example of what you're looking at roughly - I don't suggest copy and pasting this and using it live. Obviously you'll want some more security checking and stuff.
 
0
•••
Greenie said:
(renames the files to avoid collisions)

Just a note, php already does this. Files are renamed in the temp folder (although the old file name is available in the $_FILES array.
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Parking: find your domains by pasting a list
You can now paste a list of domain names into the search box at the top of the Parking menu. Put one name on each line. Your domain list...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back