|
Posted by ZeldorBlat on 09/08/06 13:16
mpar612 wrote:
> Hi everyone,
>
> I am relatively new to PHP and am having a bit of a problem with
> uploading MP3's with a form.
>
> I am creating a new directory, which does get created and I am trying
> to upload an mp3 to that directory. With the code below I constantly
> get "Please use an mpeg." If I strip away everything that limits the
> filetypes and will simply upload any file, I get "file upload failed."
>
> I did a print $audio_name and print $audio_uploaddir and the name and
> directory print out properly, but the file does not get moved to the
> directory.
>
> On this page I also have a similar piece of code that uploads an image
> and that works perfectly. I did delete that in case there could have
> been some sort of conflict, but I get the same errors that I mentioned
> above.
>
> Does anyone have any thoughts? Any help would be greatly appreciated.
> Thanks!
>
> Here is the snippet of code:
>
> $audio_dir_new = $_POST[upc];
> mkdir("../Lounge/audio/$audio_dir_new", 0777);
>
> $filetypes = array ('audio/mpeg');
> if (in_array($_FILES['upfile']['type'], $filetypes)){
> $audio_name = $_FILES['song1']['name'];
> $audio_uploaddir = "../Lounge/audio/$audio_dir_new";
> if (move_uploaded_file($_FILES['song1']['tmp_name'],
> $audio_uploaddir.'/'.$audio_name)) {
> print("file upload was successful");
> } else {
> print("file upload failed");
> }
> } else {
> print "Please use an mpeg";
> }
What does your form look like? More specifically, what is the name of
the <input> element for the file? Is it "upfile" or is it "song1" ?
Navigation:
[Reply to this message]
|