Old 19-11-2007, 08:32   #1 (permalink)
matthew22702
Registered User
 
Join Date: Nov 2007
Posts: 1
Allowing users to upload files.

Hi there. I'm new to the forum and to web design in general, I'm really hoping that I can get some advice from experienced heads.

At the moment I am designing a few pages on my iMac using Freeway Express. The main point of the pages is a form for users to pass on information. I have set it up ok, but I am really struggling with the file upload stuff. I have put the html in fine, but its all the server side stuff I get confused about. I have tried reading tutorials online but I get confused with Perl, CGI, cgi-bin folders (?), etc, etc. I don't know what much of it means at any deep level and I am thoroughly confused. I would be more than grateful if anyone could point me in the direction of a really good tutorial, or better still give me a really simple run down themselves.

I hope I have included enough information here, if not ask away.

Thanks in advance for any help,

Matthew.
  Reply With Quote
Old 19-11-2007, 17:36   #2 (permalink)
adminitrator
Registered User
 
Join Date: Oct 2006
Location: Cornwall, UK
Posts: 95
Send a message via MSN to adminitrator
Does your server support PHP?
If it does then you could use something like PHP: Handling file uploads - Manual
If you want to change the file size limits you would have to edit php.ini but other than that it's pretty simple.
  Reply With Quote
Old 19-11-2007, 18:28   #3 (permalink)
invmatt
iLurk
 
invmatt's Avatar
 
Join Date: Apr 2007
Location: England
Posts: 84
You could use something like this:

PHP Code:
<?php
function findexts ($filename)
{
    
$filename strtolower($filename) ;
    
$exts split("[/\\.]"$filename) ;
    
$n count($exts)-1;
    
$exts $exts[$n];
    return 
$exts;
}
$ext findexts ($_FILES['uploaded']['name']) ; 
    
$ran rand () ;
    
$ran2 $ran.".";
    
$target "upload/";
    
$target $target $ran2.$ext
if(
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo 
"FILE LOCATION HERE?file=".$ran2.$ext;
}
else
{
echo 
"Sorry, there was a problem uploading your file.";
}
?>

The file is uploaded and renamed to a random number (to stop people from overwriting files) I never got around to adding some sort of file type limitations or file size but it will get you started.
  Reply With Quote
Old 20-11-2007, 16:25   #4 (permalink)
adminitrator
Registered User
 
Join Date: Oct 2006
Location: Cornwall, UK
Posts: 95
Send a message via MSN to adminitrator
The file size limits are normally governed by php.ini which limits the max post size. I think the default is something like 2MB or 8MB which is fine if you just want to upload things like pictures but if you want to upload things like maybe an app then you should change this to a size which will suit your needs.
  Reply With Quote
Old 20-11-2007, 16:40   #5 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Yeah, you'll need to make sure your upload_limit and post_max_size are both within range of the file sizes you expect to work with.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8