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?
HTML form, PHP uploads and file corruption
Moderator: General Moderators
- code_monkey
- Forum Newbie
- Posts: 16
- Joined: Tue Jul 08, 2003 6:13 am
- Location: UK
- Contact:
- code_monkey
- Forum Newbie
- Posts: 16
- Joined: Tue Jul 08, 2003 6:13 am
- Location: UK
- Contact:
- code_monkey
- Forum Newbie
- Posts: 16
- Joined: Tue Jul 08, 2003 6:13 am
- Location: UK
- Contact:
Ok basics of my upload form (with a few variables removed)
And the upload code taken from the target script
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.
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>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);
?>