File upload.

Youngie1337

New member
Right, I got my own file upload written solely by me in PHP of course. Now the file upload works and filters out file types etc... Now can someone please give me a free site that has a file uploader/scripts that I can use.

I have looked and looked but they all are not what I'm looking for.

I know there is web people here like Jim and such, so please help a brother out lol.

PHP upload script - links back to file when uploaded.

Cheers.
 
name='Youngie1337' said:
Right, I got my own file upload written solely by me in PHP of course. Now the file upload works and filters out file types etc... Now can someone please give me a free site that has a file uploader/scripts that I can use.

I have looked and looked but they all are not what I'm looking for.

I know there is web people here like Jim and such, so please help a brother out lol.

PHP upload script - links back to file when uploaded.

Cheers.

Ok so lemme get this straight. The bit you've coded so far checks that the file matches one of your allowed filetypes (eg image/jpeg), yeh?

Depending on how basic/complex you want it to be the code you need to upload the file to your server should be something like:

Code:
<form action="" method="post" name="upload" target="_self" id="upload" enctype="multipart/form-data">

[b]Select Files to Upload :[/b]

<input type="file" name="file[]" size="40">

<input type="file" name="file[]" size="40">

<input type="file" name="file[]" size="40">

<input type="file" name="file[]" size="40">

<input type="file" name="file[]" size="40">

Code:
// ** CHECK FILES TRANSFERRED ** //

foreach ($_FILES["file"]["error"] as $key => $error) {

if ($error == UPLOAD_ERR_OK) {

// ** GET FILE INFO ** //

$filename = $_FILES["file"]["name"][$key];

$filetemp = $_FILES["file"]["tmp_name"][$key];

// ** MOVE UPLOADED FILE TO WEBSERVER PATH ** //

$uploadpath   = "/var/www/www.blah.com/uploads/".$filename;

move_uploaded_file($filetemp,$uploadpath);

echo "Your file has been uploaded to http://www.blah.com/uploads/".$filename;

Or have a look over at hotscripts.com :)
 
That's pretty much the same code minus some of the coding expressions. The only problem is even with this, when uploading files to the server and you then go to retrieve the file, with IE it seems to lose it's file type to .file.
 
name='Youngie1337' said:
That's pretty much the same code minus some of the coding expressions. The only problem is even with this, when uploading files to the server and you then go to retrieve the file, with IE it seems to lose it's file type to .file.

Have you tried renaming the files when they are uploaded to a random filename? I've always found filenames with spaces/strange chars choke certain browsers
 
name='Rastalovich' said:
Does this bit echo the correct name with type ?

Yep should do as $filename is derived from $_FILES["file"]["name"][$key] which is the name of each file as it was uploaded to the server from the client pc.
 
I was renaming it Jim and I think that was the problem. Also I was printing the file after upload which caused MORE problems. Now it works sweet and also will overwrite files if chosen to.

Cheers for the help.
 
Back
Top