Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Upload

Status
Not open for further replies.

RobHudson

Programmer
Apr 30, 2001
172
GB
Hi

I have a file upload script and am having some odd occurences. I am able to upload a file of 5mb (it does take about 4 minutes with my connection) using the script. Other people using the script are not having the same success. One user reported a wait of 15 minutes and the file was not uploaded and the browser just stayed blank.

I have checked that the file upload limit is higher enough (which it would have to be for it to work for me) and have set set_time_limit(0). There is sufficient space on the server and all permissions are ok. All users are using a broadband connection.

Any ideas why this could be happening?

Cheers
Rob
 
check the upload_max_filesize directive in php.ini

 
Hi jpadie

upload_max_filesize is 10mb. So the file is well within the limits.

The odd things is that I can upload the file and the users can not upload the same file.
 
are you receiving any error messages either in your logs or in the source code of the failed page that they receive (note that the errors often don't appear visible to the user).

are you including a max_file_size directive in your forms?
 
RobHudson could u share php upload scripte. I am intrested in same thing.Thanks
 
Here ya go...

Code:
function doUpload($uploadedFile, $uploadLocation, $newName = "") {
		//Upload passed file to the given location
		//Deal with using a new name
		if ($newName != "") {$fileName = $newName;} else {$fileName = $uploadedFile["name"];}
		
		//Do it!
		if (is_uploaded_file($uploadedFile["tmp_name"])) {
			//Delete the old file first [if there was one]
			if (file_exists(filePath.$uploadLocation.folderDelimiter.$fileName)) {unlink(filePath.$uploadLocation.folderDelimiter.$fileName);}
			
			//Attempt copy
			if (!copy($uploadedFile["tmp_name"], filePath.$uploadLocation.folderDelimiter.$fileName)) {
				//Copy failed
				print "Not copied<br>";
				return false;
			}
		} else {
			//Upload failed
			print "Not uploaded<br>";
			return false;
		}
		return true;
	}

$uploadedFile is the $_FILE object.
filePath and folderDelimiter are constants. folderDelimiter is either / or \ depending on the server OS.

Hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top