HTML form, PHP uploads and file corruption

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
code_monkey
Forum Newbie
Posts: 16
Joined: Tue Jul 08, 2003 6:13 am
Location: UK
Contact:

HTML form, PHP uploads and file corruption

Post 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?
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

Could we see some code?
User avatar
code_monkey
Forum Newbie
Posts: 16
Joined: Tue Jul 08, 2003 6:13 am
Location: UK
Contact:

Post 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.
almostsane
Forum Newbie
Posts: 13
Joined: Sat Jan 10, 2004 3:26 am

Post by almostsane »

but can we see the code
User avatar
code_monkey
Forum Newbie
Posts: 16
Joined: Tue Jul 08, 2003 6:13 am
Location: UK
Contact:

Post 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.
Post Reply