Jump to content

uploading problem


corillo181

Recommended Posts

i got a code to upload picture i triad it to upload music but is not wokring is there a special way or music than picture?

this is the code.

[code]
<?php
$dir='../music/hmp/';
$filesize = $_FILES['sfile']['size'];
$filetype = $_FILES['sfile']['type'];
$filename = $_FILES['sfile']['name'];
$pos = strrpos($filename, '.');
$newname = $song . substr($filename, $pos);
$filepath = $dir . $newname;

$result=copy($tmpname, $filepath);
if(!$result){ echo " a problem occur";
}
?>[/code]
Link to comment
Share on other sites

well i dont trust my eyes any longer so it still not wokring is it something i dont see?
[code]
<?php
include_once'../includes/db.php';
//get variable

$dir='../music/hmp/';
$filesize = $_FILES['sfile']['size'];
$filetype = $_FILES['sfile']['type'];
$filename = $_FILES['sfile']['name'];
$tmpname = $_FILES['sfile']['tmp_name'];
$pos = strrpos($filename, '.');
$newname = $song . substr($filename, $pos);
$filepath = $dir . $newname;

$result=copy($tmpname, $filepath);
if(!$result){ echo " a problem occur";
}
?>
[/code]
Link to comment
Share on other sites

yes it is..

like i said.. this code i took it from one of my already working codes.. i have it as a gallery in a website..

i just never used it to upload music..i was trying to see if it works with music but is not working.

[code]
<form action="../phpscripts/muls.php" method="post" enctype="multipart/form-data" name="ulmusic" id="ulmusic">
  <table border="0">
   
    <tr>
      <td>song_name</td>
      <td><label>
        <input name="song" type="text" id="song" />
      </label></td>
    </tr>
    <tr>
      <td><label>song:</label></td>
      <td><input name="ulfile" type="file" id="ulfile" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="UpLoad" /></td>
    </tr>
  </table>
</form>
[/code]
[code]<?php
include_once'../includes/db.php';
//get variable

$dir='../music/hmp/';
$filesize = $_FILES['sfile']['size'];
$filetype = $_FILES['sfile']['type'];
$filename = $_FILES['sfile']['name'];
$tmpname = $_FILES['sfile']['tmp_name'];
$pos = strrpos($filename, '.');
$newname = $song . substr($filename, $pos);
$filepath = $dir . $newname;

$result=copy($tmpname, $filepath);
if(!$result){ echo " a problem occur";
}
?>[/code]
Link to comment
Share on other sites

No its not...

[code]<?php
include_once'../includes/db.php';
//get variable

$dir='../music/hmp/';
$filesize = $_FILES['ulfile']['size'];
$filetype = $_FILES['ulfile']['type'];
$filename = $_FILES['ulfile']['name'];
$tmpname = $_FILES['ulfile']['tmp_name'];
$pos = strrpos($filename, '.');
$newname = $song . substr($filename, $pos);
$filepath = $dir . $newname;

$result=copy($tmpname, $filepath);
if(!$result){ echo " a problem occur";
}
?>[/code]
Link to comment
Share on other sites

nah i gave you the wrong code it still the same
[code]
<form action="../phpscripts/muls.php" method="post" enctype="multipart/form-data" name="ulmusic" id="ulmusic">
  <table border="0">
   
    <tr>
      <td>song_name</td>
      <td><label>
        <input name="song" type="text" id="song" />
      </label></td>
    </tr>
    <tr>
      <td><label>song:</label></td>
      <td><input name="sfile" type="file" id="ulfile" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="UpLoad" /></td>
    </tr>
  </table>
</form>
[/code]
[code]
<?php
include_once'../includes/db.php';
//get variable
$song=$_POST['song'];
$dir='../music/hmp/';
$filesize = $_FILES['sfile']['size'];
$filetype = $_FILES['sfile']['type'];
$filename = $_FILES['sfile']['name'];
$tmpname = $_FILES['sfile']['tmp_name'];
$pos = strrpos($filename, '.');
$newname = $song . substr($filename, $pos);
$filepath = $dir . $newname;

$result=copy($tmpname, $filepath);
if(!$result){ echo " a problem occur";
}
?>
[/code]
Link to comment
Share on other sites

Hi there,

Here is a brilliant file upload script i used for my tafe project, i tested it and it can upload just about any file format you just need to get rid of the file format restrictions up top

Here is the link: [url=http://www.w3schools.com/php/php_file_upload.asp]http://www.w3schools.com/php/php_file_upload.asp[/url]
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.