file_exists ?

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

User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

There is already a file called on our server. please rename this file
I just noticed that....that's the problem then :o
$mp3file isn't set or is empty. Do a var_dump($_FILES['mp3file']) and post the output.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

i did this

Code: Select all

$dump = var_dump($_FILES['mp3file']);
   echo "$dump";
And this is the full out put:

array(5) { ["name"]=> string(0) "" ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(4) ["size"]=> int(0) } There is already a file called on our server. Please rename this file.

Click the Back button and RE-SUBMIT./www/n/a/naild.com/htdocs/localmm/upload/Ataris - Let It Go.mp3
/www/n/a/naild.com/htdocs/localmm/upload/FUL-FAC-SHUN - Crass Course.mp3
/www/n/a/naild.com/htdocs/localmm/upload/FUL-FAC-SHUN - Eye to Eye.mp3
/www/n/a/naild.com/htdocs/localmm/upload/FUL-FAC-SHUN - Fit for Unsertenty.mp3
/www/n/a/naild.com/htdocs/localmm/upload/FUL-FAC-SHUN - Work.mp3
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

It didn't get uploaded then as the array is empty.
Can you post the form you use to upload and the size of the mp3 file you are trying to upload?
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

Code: Select all

<FORM enctype="multipart/form-data" ACTION="http://naild.com/localmm/modules.php?name=Band_Submit&file=upload" METHOD="POST"> 
Band Name:<br>
<input type="text" name="band_name"size=40><br>
Description:<br>
<textarea cols=65 rows=10 name="description"></textarea><br>
History:<br>
<textarea cols=65 rows=10 name="history"></textarea><br> 
Influences:<br>
<input type="text" name="influences"size=65><br>
<br>
Select Genra:<br>
<select name="genra"><br>
<option>------Click Here-----</option>
<option value="Acoustic">Acoustic</option> 
<option value="Alternative">Alternative</option>
<option value="Blues">Blues</option>
<option value="Christian">Christian</option> 
<option value="Classic_Rock">Classic Rock</option> 
<option value="Classical">Classical</option> 
<option value="Country">Country</option> 
<option value="Cover_Bands">Cover Bands</option> 
<option value="Death_Metal">Death Metal</option> 
<option value="Disc_Jockey">Disc Jockey</option> 
<option value="Easy_Listening">Easy Listening</option> 
<option value="Electronic">Electronic</option> 
<option value="Emo">Emo</option>
<option value="Experimental">Experimental</option> 
<option value="Folk">Folk</option> 
<option value="Funk">Funk</option> 
<option value="Gospel">Gospel</option> 
<option value="Gothic">Gothic</option> 
<option value="Grunge">Grunge</option> 
<option value="Hardcore">Hardcore</option> 
<option value="Hip_Hop">Hip Hop</option> 
<option value="Instrumental">Instrumental</option> 
<option value="Jazz">Jazz</option> 
<option value="Metal">Metal</option> 
<option value="Modern_Rock">Modern Rock</option>
<option value="Progressive">Progressive</option>
<option value="Punk">Punk</option>
<option value="Rap">Rap</option> 
<option value="Reggae">Reggae</option> 
<option value="Rock">Rock</option>
<option value="Ska">Ska</option>
<option value="Speed_Metal">Speed Metal</option> 
<option value="Swing">Swing </option>
</select>
<br>
<br> 
   Email:<br>
   <input type="text" name="email"size=40><br>
   <br>
   Website:<br>
   <input type="text" name="website"size=40 value="http://"><br>
   <br>
   Upload files:<BR>
    <i>Click Browse than browse to your file</i><br>
   <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="200000" />
   Image File: (200 kb max)<br>
   <INPUT TYPE="FILE" NAME="imagefile" SIZE="50">&nbsp <i>(IF you do select an image file or mp3 file to upload, UPLOAD TIMES MAY VARY. The page will appear to be loading, but thats the upload in progress)</i><BR>
   <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="6000000" />
   Mp3/.avi/.mpg/.mpeg/.zip File: (6MB max)<br>
   <INPUT TYPE="FILE" NAME="mp3file"  SIZE="50"><BR> 
   <INPUT TYPE="submit" name="submit" value="submit"><BR>
</form>
Whoops.. For now im just uploading a single image that is 8 kb
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yay! Found the problem (i think) :o
The problem is the file size of the mp3 you are uploading, it's not actually affected by the 6M thing, i.e if you upload one that's under 2M it will probably work as 2M is the default upload_max_filesize in php.ini.
So, just to check this is the problem try setting upload_max_filesize in your php.ini to 6M and restarting apache.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

Im only uploading a 8 kb image file not an mp3. and im hosted from a company so how would i restart apache?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yeah, it's the size of the mp3 that's the problem. Try putting the following in a .htaccess file in the same directory as the form.

php_value upload_max_filesize 6M
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

ooook
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

i got a phpinfo.php and it shows that my max upload size is already set at 8 mb
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Well, all i can say is it's definetly down to the size of the mp3 file, i've tried your code locally and it ignores the 6M limit you set it the form and instead picks up the default php.ini value of 2M. Just as a test does uploading an mp3 file of less that 2M work ok? That would confirm what i'm seeing here.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

So you want me to try uploading an image and an mp3 and the mp3 should be less than 2 mb that i upload?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yup
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

it worked... HMMMM how can i fix this?
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

i dont want my users to be required to upload an mp3 or image file...
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Did you try putting
php_value upload_max_filesize 6M
in a .htaccess file?
Post Reply