problem uploading

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
i made me a php uploader for my site but i cant seem to upload a movie.... altho nothing in the code it blocking it.... no errors or anything... just it keeps loading very long then says page not found ....

i did it like this
copy($_FILES[movie][tmp_name]; "uploads/video/");
also tried move_uploaded_file($_FILES[movie][tmp_name]; "uploads/video/");

this is kinda urgent :( depending on my site's rep anybody wanna give a hand? please
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
i just changed my code into this it still makes the same mistake
PHP:
<?
///smilies
echo "<script language=\"javascript\">
<!--
function writeImgTag(code)
{
var cache = document.form1.comment.value;
this.code = code;
document.form1.comment.value = cache + code;
document.form1.comment.focus();
}
//-->
</script>";
$befor = array(':)',':(',':p','B)','rolly','(l)',':ninja:',';)','<_<',':s',':o',':D',':wtf:');
$after = array("<img onClick=\"writeImgTag(' :) ')\" src=\"smilies/smile.gif\" >","<img onClick=\"writeImgTag(' :( ')\" src=\"smilies/frown.gif\">","<img onClick=\"writeImgTag(' :p ')\" src=\"smilies/tongue.gif\">","<img onClick=\"writeImgTag(' B) ')\" src=\"smilies/cool.gif\">","<img onClick=\"writeImgTag(' rolly ')\" src=\"smilies/rolleyes.gif\">","<img onClick=\"writeImgTag(' (l) ')\" src=\"smilies/wub.gif\">","<img onClick=\"writeImgTag(' :ninja: ')\" src=\"smilies/ph34r.gif\">","<img onClick=\"writeImgTag(' ;) ')\" src=\"smilies/wink.gif\">","<img onClick=\"writeImgTag(' <_< ')\" src=\"smilies/dry.gif\">","<img onClick=\"writeImgTag(' :s ')\" src=\"smilies/unsure.gif\">","<img onClick=\"writeImgTag(' :o ')\" src=\"smilies/ohmy.gif\">","<img onClick=\"writeImgTag(' :D ')\" src=\"smilies/biggrin.gif\">","<img onClick=\"writeImgTag(' :wtf: ')\" src=\"smilies/blink.gif\">");
///smilies

if($_POST[Submit])
{

if ($_POST[type] == "foto")
{
$subfolder = "$_POST[type]/$_POST[subfolder]";
}
else
{
$subfolder = "$_POST[type]";
}
//$uploadfile = str_replace(" ","_",$_FILES['userfile']['name']);
$url = "/uploads/" . $subfolder . "/hyeclass_www_swb_24ex_com_".$_FILES['userfile']['name'];
// variables
$ftp_server = "64.111.117.241";
$ftp_user_name = "bugz";
$ftp_user_pass = "aperik11";
$destination_file = "/bugz.fateware.net/swb/uploads/" . $subfolder . "/hyeclass_www_swb_24ex_com_".$_FILES['userfile']['name'];
$sourcefile = $_FILES['userfile']['name'];

// set up basic connection
$conn_id = ftp_connect($ftp_server); 

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

// check connection
if ((!$conn_id) || (!$login_result)) { 
       echo "FTP connection has failed!";
       echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
       exit; 
   } else {
       echo "Connected to $ftp_server, for user $ftp_user_name";
   }

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);  // line 30

// check upload status
if (!$upload) { 
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }

// close the FTP stream 
ftp_close($conn_id); 

if (!$_POST[type] == "foto")
{
$title = htmlspecialchars("$_POST[title]");
$type = $_POST[type];
$comment = htmlspecialchars("$_POST[comment]");
$date = date("d / m / Y");

$add = mysql_query("INSERT into files (title, url, date, adder, comment, type) VALUES('$title','$url','$date','$logged[gebruiker]','$comment','$type')");
}
}
else
{
echo "<form name=\"form1\" enctype=\"multipart/form-data\" method=\"post\" action=\"\">
Het bestand: 
  <input type=\"file\" name=\"userfile\">
<br>
  Titel:
  <input name=\"title\" type=\"text\"><br> 
  Type : 
  <select name=\"type\" id=\"type\">
    <option value=\"foto\">Foto</option>
    <option value=\"video\">Video</option>
    <option value=\"muziek\">Muziek</option>
      </select><br>
  *Album(alleen bij foto's): 
  <select name=\"subfolder\" id=\"subfolder\">
    <option value=\"2006\">2006 zomer</option>
    <option value=\"swb\">SWB de wijk</option>
    <option value=\"andere\">Andere</option>
  </select><br>
  Commentaar: 
  <textarea name=\"comment\" id=\"comment\"></textarea> <table width=\"100\" height=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">
          <tr>
            <td>$after[0]</td>
            <td>$after[4]</td>
            <td>$after[8]</td>
            <td>$after[12]</td>
          </tr>
          <tr>
            <td>$after[1]</td>
            <td>$after[5]</td>
            <td>$after[9]</td>
            <td>$after[13]</td>
          </tr>
          <tr>
            <td>$after[2]</td>
            <td>$after[6]</td>
            <td>$after[10]</td>
            <td>$after[14]</td>
          </tr>
          <tr>
            <td>$after[3]</td>
            <td>$after[7]</td>
            <td>$after[11]</td>
            <td>$after[15]</td>
          </tr>
        </table>
  <br><br>
  <input type=\"submit\" name=\"Submit\" value=\"Ok!\">
</form>";
}
?>

anybody know what i'm doing wrong?
 

Torch

New Member
Messages
634
Reaction score
0
Points
0
Make sure that your php file isn't CHMOD 777. If it is, change it to 755.

Also, here is a simple upload script in case you can't make your work:

PHP:
<html>
<head>
<title>Upload Files</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#000000"><font color="#ffffff" family="Verdana"><b>
			<table width="100%" height="280"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="10%">&nbsp;</td>
              </tr>
              <tr>
                <td height="80%">
<?php 


$pw = 'pass';

$dir = "dir/"; 

$types = array("application/pdf","image/png","image/x-png","audio/wav","image/gif","image/jpeg","image/pjpeg","application/x-zip-compressed","warcraft/model-com","mdx","application/octet-stream");
    

//Function to do a directory listing
function scandir($dirstr) {
	echo "<pre>\n";
	passthru("ls -l -F $dirstr 2>&1 ");
	echo "</pre>\n";
}

//Check to determine if the submit button has been pressed 
if((isset($_POST['submit'])) and ($_POST['PW'] == $pw)){ 

	//Shorten Variables 
	$tmp_name = $_FILES['upload']['tmp_name']; 
	$new_name = $_FILES['upload']['name']; 
	$path = $_POST['subdir'];
	$fullpath = "$dir$path/";
	$fullpath = str_replace("..", "", str_replace("\.", "", str_replace("//", "/", $fullpath)));
	$clean_name = ereg_replace("[^a-z0-9._]", "", str_replace(" ", "_", str_replace("%20", "_", strtolower($new_name) ) ) );

// lets see if we are uploading a file or doing a dir listing
	if(isset($_POST['Dir'])){
		echo "Directory listing for $fullpath\n";
		scandir("$fullpath");
		}else{


		//Check MIME Type 
		if ((in_array($_FILES['upload']['type'], $types)) and (!file_exists($fullpath.$clean_name))){ 

			// create a sub-directory if required
			if (!is_dir($fullpath)){
				mkdir("$fullpath", 0755);
			}
			//Move file from tmp dir to new location 
			move_uploaded_file($tmp_name,$fullpath . $clean_name); 
 
			echo "$clean_name of {$_FILES['upload']['size']} bytes was sucessfully uploaded!";

		}else{ 
          
			//Print Error Message 
			echo "<small>File <strong><em>{$_FILES['upload']['name']}</em></strong> Was Not Uploaded - bad file type or file already exists</small><br />"; 
			//Debug 
			$name =  $_FILES['upload']['name']; 
			$type =    $_FILES['upload']['type']; 
			$size =    $_FILES['upload']['size']; 
			$tmp =     $_FILES['upload']['name']; 
    
			echo "Name: $name<br />Type: $type<br />Size: $size<br />Tmp: $tmp";

		} 
      
	} 
} else { 
	echo 'Ready to upload your file';
} ?> 
          
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> 
      
<!--<fieldset>--> 
<!--<legend>Upload File</legend><br />--> 

Password:  <input type="password" name="PW" /><br /><!--
Do a directory Listing  <input type="checkbox" name="Dir" value="on" /><br />-->
File:  <span style="input {border:1px solid #000000; background: #ffffff};"><input style="input {border:1px solid #000000; background: #ffffff};" type="file" name="upload" /></span> <br /><br /><!--
Subdir to upload to/list directory: <input type="text" name="subdir" value="<?php $path = $_POST['subdir']; echo "$path";?>" /> (Can be blank) **Directory will be created if it does not exist<br />-->
<center><input type="submit" name="submit" value="Upload" /></center>
<!--</fieldset>--> 
</form>
				</td>
              </tr>
              <tr>
                <td height="10%">&nbsp;</td>
              </tr>
            </table>
</body>
</html>
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
i've got the feeling that its not the script cause i've tried the way u do it ... also same thing....
is it possible its the host thats blocking something? and is there a way around?
and i just checked the permissions were set to 644 could that be the problem?
 
Last edited:

Torch

New Member
Messages
634
Reaction score
0
Points
0
Well, did you make sure that your files aren't CHMOD 777? Because php files with 777 doesn't work on this server, you have to CHMOD them to 755.
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
well..its not on this server its on dreamhost butyea ive chmodded it to 755 ut the thing is it has no problem with small files i'm guessing 1 - 5 mb...
 

Torch

New Member
Messages
634
Reaction score
0
Points
0
You shouldn't ask for support with sites that aren't hosted here...but anyway, I didn't really understood your last post, did you get it to work properly or now?
Also, you have to add MIME type of files you wish to upload on list in my script. This is the array you need to edit (around line 20):
$types = array("application/pdf","image/png","image/x-png","audio/wav","image/gif","image/jpeg","image/pjpeg","application/x-zip-compressed","application/octet-stream");
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
well no i didn't get it to work... but its not the mime type thats causing this....cause it uploads small wmv files but not big ones
 

Torch

New Member
Messages
634
Reaction score
0
Points
0
Ah, well, than it's your host. They probably don't allow large files.
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
oh but when using phpftp they cant realy block it right?
//the error is connection reset....
 

Torch

New Member
Messages
634
Reaction score
0
Points
0
Yep, they can. If they don't allow files of certian size, there is no way you can get around it.
 
Top