Page 1 of 3

New SIMPLE upload script not workin

Posted: Sat Feb 14, 2004 11:28 pm
by mikegotnaild
It will show the file being transfered. And it will go all the way through without any errors. But when i go to my ftp and look in the upload directory nothing is there. CHMOD is 777 btw. Heres the code.
form.php

Code: Select all

<?
if(!eregi("modules.php", $_SERVER&#1111;'PHP_SELF']))&#123; 
     die("You can't access this file directly..."); 
&#125; 

$module_name = basename(dirname(__FILE__)); 
$module_dir = "modules/$module_name/"; 
include("header.php"); 
$index = 1;//right sidebar or not 0=off 1=on 
title("Submit Band info/Mp3's"); 
OpenTable(); 
?> 
   <br>You may upload TWO mp3s that are no more than 3.5mb each. If one mp3 is more than
   3.5mb. You may only upload ONE. If you do not abide by this rule all information will be Discarded.
   <br>
   <FORM ACTION="http://naild.com/localmm/modules?=Bands_Showcase&file=upload" METHOD="POST" ENCTYPE="multipart/form-data"> 
   
   Browse to files:<BR>
   
   <INPUT TYPE="FILE" NAME="firstfile" SIZE="50"><BR> 
   <INPUT TYPE="FILE" NAME="secondfile" SIZE="50"><BR>
   <INPUT TYPE="SUBMIT"> 
</FORM>
<?php 
CloseTable(); 
include("footer.php"); 
?>
upload.php

Code: Select all

<?php 
 
   $uploaddir = "/localmm/upload/"; 
   $uploadfile1 = $uploaddir . $_FILES&#1111;'firstfile']&#1111;'name']; 
   $uploadfile2 = $uploaddir . $_FILES&#1111;'secondfile']&#1111;'name']; 
   
   if (!move_uploaded_file($_FILES&#1111;'firstfile']&#1111;'tmp_name'], $uploadfile1)) &#123; 
       print "ERROR: File is invalid"; 
       print_r($_FILES); 
   &#125; 

   if (!move_uploaded_file($_FILES&#1111;'secondfile']&#1111;'tmp_name'], $uploadfile2)) &#123; 
       print "ERROR: File is invalid"; 
       print_r($_FILES); 
   &#125;

?>

Posted: Sat Feb 14, 2004 11:37 pm
by markl999
Notice that you arn't posting direectly to upload.php so it's worth noting that uploaded files get removed if you don't move them immediately.

Posted: Sat Feb 14, 2004 11:46 pm
by mikegotnaild
im not trying to get people to write scripts for me but this is just one of those times where i need that kind of visual aid. :/ Ive been here all day trying to figure this out.

Posted: Sat Feb 14, 2004 11:52 pm
by markl999
Well, there's one of 2 things going wrong, either the upload part just plain isn't working or the rest of the code is getting in the way..all that module stuff etc..
So i'd remove the extra code complication. Copy the example code from http://www.php.net/manual/en/features.f ... ltiple.php and run it as a totally separate file, i.e outside of your code (tweak the example to match your setup). If that works then the problem lies not in the actual uploading but in the 'surrounding code'.

Posted: Sat Feb 14, 2004 11:53 pm
by mikegotnaild
Do you mean this user submitted example from that page?

Code: Select all

<FORM ACTION="upload.php" METHOD="POST" ENCTYPE="multipart/form-data"> 
   Send these files:<BR> 
   <INPUT TYPE="FILE" NAME="firstfile" SIZE="50"><BR> 
   <INPUT TYPE="FILE" NAME="secondfile" SIZE="50"><BR> 
   <INPUT TYPE="SUBMIT"> 
</FORM> 

And in 'upload.php' have the following code: 

<?PHP 

   $uploaddir = "uploads/"; 
   $uploadfile1 = $uploaddir . $_FILES&#1111;'firstfile']&#1111;'name']; 
   $uploadfile2 = $uploaddir . $_FILES&#1111;'secondfile']&#1111;'name']; 
   
   if (!move_uploaded_file($_FILES&#1111;'firstfile']&#1111;'tmp_name'], $uploadfile1)) &#123; 
       print "ERROR: File is invalid"; 
       print_r($_FILES); 
   &#125; 

   if (!move_uploaded_file($_FILES&#1111;'secondfile']&#1111;'tmp_name'], $uploadfile2)) &#123; 
       print "ERROR: File is invalid"; 
       print_r($_FILES); 
   &#125; 

?>

Posted: Sat Feb 14, 2004 11:56 pm
by markl999
Yes, just tweak the upload paths etc to match your server setup.

Posted: Sun Feb 15, 2004 12:00 am
by mikegotnaild
so all i really need to tweak is this $uploaddir = "uploads/"; right?

Posted: Sun Feb 15, 2004 12:01 am
by markl999
yup

Posted: Sun Feb 15, 2004 12:13 am
by mikegotnaild
Now im getting this error when upload is finished
ERROR: File is invalidArray ( [firstfile] => Array ( [name] => Ataris - Are We There Yet.mp3 [type] => audio/mpeg [tmp_name] => /var/tmp/phpwi03Jj [error] => 0 [size] => 1061605 ) [secondfile] => Array ( [name] => Ataris - Let It Go.mp3 [type] => audio/mpeg [tmp_name] => /var/tmp/phppGnUQr [error] => 0 [size] => 1398619 ) ) ERROR: File is invalidArray ( [firstfile] => Array ( [name] => Ataris - Are We There Yet.mp3 [type] => audio/mpeg [tmp_name] => /var/tmp/phpwi03Jj [error] => 0 [size] => 1061605 ) [secondfile] => Array ( [name] => Ataris - Let It Go.mp3 [type] => audio/mpeg [tmp_name] => /var/tmp/phppGnUQr [error] => 0 [size] => 1398619 ) )

Posted: Sun Feb 15, 2004 12:15 am
by markl999
What does your $uploaddir = look like?

Posted: Sun Feb 15, 2004 12:16 am
by mikegotnaild
index.html

Code: Select all

<html>

<FORM ACTION="upload.php" METHOD="POST" ENCTYPE="multipart/form-data"> 
   Send these files:<BR> 
   <INPUT TYPE="FILE" NAME="firstfile" SIZE="50"><BR> 
   <INPUT TYPE="FILE" NAME="secondfile" SIZE="50"><BR> 
   <INPUT TYPE="SUBMIT"> 
</FORM>
</html>
upload.php

Code: Select all

<?PHP 

   $uploaddir = "/localmm/upload/"; 
   $uploadfile1 = $uploaddir . $_FILES&#1111;'firstfile']&#1111;'name']; 
   $uploadfile2 = $uploaddir . $_FILES&#1111;'secondfile']&#1111;'name']; 
   
   if (!move_uploaded_file($_FILES&#1111;'firstfile']&#1111;'tmp_name'], $uploadfile1)) &#123; 
       print "ERROR: File is invalid"; 
       print_r($_FILES); 
   &#125; 

   if (!move_uploaded_file($_FILES&#1111;'secondfile']&#1111;'tmp_name'], $uploadfile2)) &#123; 
       print "ERROR: File is invalid"; 
       print_r($_FILES); 
   &#125; 

?>

Posted: Sun Feb 15, 2004 12:18 am
by markl999
If /localmm/upload/ is in your document root then you might want to try
$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/localmm/upload/';

Or is /localmm/upload/ a 'root' directory?

Posted: Sun Feb 15, 2004 12:20 am
by mikegotnaild
my webserver is set up like htdocs/

Posted: Sun Feb 15, 2004 12:21 am
by mikegotnaild
the full path would be htdocs/localmm/upload

Posted: Sun Feb 15, 2004 12:21 am
by markl999
Sounds like you want $uploaddir = $_SERVER['DOCUMENT_ROOT'].'/localmm/upload/'; then ..

also..
put error_reporting(E_ALL); at the top of upload.php ..
<?php
error_reporting(E_ALL);