Page 1 of 1

HTML form, PHP uploads and file corruption

Posted: Wed Jan 14, 2004 7:17 am
by code_monkey
Hello,

I've been experiencing some odd problems with a php script I created for uploading quicktime movies. When I upload files using my script on my computer they upload correctly with no problems. When someone else on a different machine and different internet connection uploads the same file using the script it becomes corrupted.

I'm assuming my script is working correctly as it uploads the files perfectly for me and I'm wondering if anyone is aware of any other possible causes for this type of behaviour for an upload script. My thinking is it must be something to do with their internet connection or OS, but I thought maybe someone else might have experienced similar errors and be able to suggest other causes.

Any ideas?

Posted: Wed Jan 14, 2004 5:36 pm
by uberpolak
Could we see some code?

Posted: Thu Jan 15, 2004 5:00 am
by code_monkey
I think the problem was client side rather than an error with my script, we're leaning towards thinking it was norton antivirus corrupting the uploads.

Posted: Thu Jan 15, 2004 5:55 am
by almostsane
but can we see the code

Posted: Thu Jan 15, 2004 6:28 am
by code_monkey
Ok basics of my upload form (with a few variables removed)

Code: Select all

<form action="../clips/index.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="func" value="insert_details">
<table class="bodytext" width="100%" cellspacing=5 cellpadding=5 >
<tr>
      <td>Preview clip</td><td><input type="file" name="preview"></td>
</tr>
<tr>
     <td colspan="2" align="right"><input type="submit" name="submit" value="Upload"></td>
</tr>	
</table>
</form>
And the upload code taken from the target script

Code: Select all

<?php

$preview_upload =  $_FILES["preview"];

if($preview_upload['tmp_name']!="none"){

	$preview_filename = $preview_upload['name'];

	if(file_exists ("/path/".$preview_filename)){
	
		// send browser back to edit page with success message
	
		$error="preview_file_taken";					
	
	}
	else{

		$movie = $preview_upload['tmp_name'];
	
		$uploadstring = "/path/".$preview_filename;

		$success = move_uploaded_file($movie,$uploadstring);
	
		if($success){
			
			$previewclip_upload=1;
			
			$preview_unique_id = md5(uniqid(rand(),1));

			$token_result = mysql_query("SELECT clip_preview_id FROM Clip_preview WHERE clip_preview_id ='$preview_unique_id'",$db);

			while($num_rows = mysql_num_rows($token_result)){
									
				$preview_unique_id = md5(uniqid(rand(),1));	
									
			}					
			
			$upload_result = mysql_query("INSERT INTO Clip_preview (clip_preview_id,filename,clip_id,duration) VALUES('$preview_unique_id','$preview_filename','$clips_unique_id','$duration')",$db);

?>
After this there's a bit of error checking and then the script forwards to another page. I've chopped out the code before as this isn't relevant. Hopefully it makes sense. There's not an awful lot to the upload side of the script to go wrong really, and I'm fairly certain its the client machine or its connection now.