Jump to content

uploading mp3/wma etc.


daled

Recommended Posts

This has me clueless:

 

form:

<form action="process.php?action=upload<?php echo $_GET['info']; ?>" method="POST" enctype="multipart/form-data">
<input type="file" name="music1" size=30 class="field2" />
<input type="submit" value="Upload" class="submit" />
</form>

 

code:

if(isset( $_FILES['music1']['name'] ) and ( $_FILES['music1']['name'] != '' )){
	copy( $_FILES['music1']['tmp_name'], 'C:/Program Files/Apache Group/Apache2/htdocs/Record Label/Second Layout/Files/'.$_FILES['music1']['name'] ) or die("Could not upload Song 1");
};

 

The troubling thing is that the code works with pictures and application files.  I think that the form isn't creating a ['tmp_name'] for the file because it does for pictures etc. 

 

any help would be nice. thanks.

Link to comment
Share on other sites

try it - just use a regular dump of the results and see what gives. it may also be worth checking the size of the actual file to make sure your limits are big enough to accept it.

 

<?php
if ($_FILES)
{
   echo '<pre>';
   print_r($_FILES);
   echo '</pre>';
}
?>

 

i'm not actually sure it's relevent to your problem, but move_uploaded_file is generally more commonly used for file uploads

Link to comment
Share on other sites

here's what i got:

 

    [music1] => Array

        (

            [name] => Dark Blue.mp3

            [type] =>

            [tmp_name] =>

            [error] => 1

            => 0

        )

 

When i put in a jpg (into another upload on the same page):

 

    [thumbnail] => Array

        (

            [name] => 100_0838.JPG

            [type] => image/jpeg

            [tmp_name] => C:\PHP\uploadtemp\phpA57.tmp

            [error] => 0

            => 607604

        )

 

interpretations?

Link to comment
Share on other sites

The error array element being set to "1" leads me to believe there was an error reading the file.

 

Have you tried other mp3 files? Perhaps try a very small mp3 (sound byte under 500k would be a good test) to see if your PHP configuration limit for max_post_size is too low (the setting for all parts of a form submission).'

Link to comment
Share on other sites

now i have another problem, maybe they're linked.

 

i'm trying to put a 4 mb limit on picture uploads, but when i try to upload a large file, it still executes the sql code to insert a new row, but doesn't upload the file: 

 

form:

<b>Max Size:</b> 4mB<br>
<b>Allowed Formats:</b> .jpg .gif .png<br />
Be aware that .png does not view correctly on Internet Explorer 6.<br /><br />
<form action="manage.php?action=upload&info=pictures" method="post" enctype="multipart/form-data">
<input type="file" name="picture1" size=45 class="field2" />
<br />
<input type="file" name="picture2" size=45 class="field2" />
<br />
<input type="file" name="picture3" size=45 class="field2" />
<br />
<input type="file" name="picture4" size=45 class="field2" />
<br />
<input type="file" name="picture5" size=45 class="field2" />
<br />
<center>
<br />
<span class="h3">
<BR />
<input type="submit" value="Upload" class="submit" />
<input type="hidden" value="upload" name="upload"  />
</span>
</center>
</form>

 

php code (this is the same for all the form):

<?php
if(isset( $_POST['upload'] ) and ( $_POST['upload'] == "upload" )){
if(isset( $_FILES['picture1']['name'] ) and ($_FILES['picture1']['name'] != "" )){
	if(( $_FILES['picture1']['size'] < 4194304 ) and ( $_FILES['picture1']['type'] == "image/png" or "image/jpeg" or "image/gif" or "image/pjpeg" or "image/x-png" or "image/gif")){
		//upload
		move_uploaded_file( $_FILES['picture1']['tmp_name'], "C:/Program Files/Apache Group/Apache2/htdocs/Record Label/Second Layout/Files/".$_FILES['picture1']['name'] );

		//sql query
		$database = $_COOKIE['number'];
		$conn = mysql_pconnect('localhost', 'root', '');
		mysql_select_db($database, $conn);
		$query_journal = sprintf("INSERT INTO `pictures` (url) VALUES ('%s')", "Files/".$_FILES['picture1']['name']);
		$journal = mysql_query($query_journal, $conn) or die(mysql_error());

		$pic1 = 'Picture 1 has been uploaded successfully<br>';
		$pic15 = $_FILES['picture1']['size'];
		$pic155 = $_FILES['picture1']['type'];

	}else{
		$pic1 = "Picture 1 too large";
	};
};
};
?>

 

now i'm totally baffled!

Link to comment
Share on other sites

upped max execution time from 30 to 3600. still no good:

 

with an mp3

[music1] => Array

        (

            [name] => To Youth.mp3

            [type] =>

            [tmp_name] =>

            [error] => 1

            => 0

        )

 

with a jpg

[music1] => Array

        (

            [name] => pieceFINAL.jpg

            [type] =>

            [tmp_name] =>

            [error] => 1

            => 0

        )

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.