www.webdeveloper.com
Results 1 to 2 of 2

Thread: Move Uploaded File > Quick problem

  1. #1
    Join Date
    Mar 2005
    Posts
    172

    Move Uploaded File > Quick problem

    Hi Guys,

    Very quick one. I'm trying to upload a file and force an extension name on it:

    PHP Code:
    $file_exten ".wmv"

    if(
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], "../../../story_media/video/".$_SERVER['REMOTE_ADDR'].time(), $file_exten)){ 
    As you can see I have created a variable to do this, but it throws up an error can't move uploaded file.

    However if I have this code without the $file_exten - ie:

    PHP Code:
    $file_exten ".wmv"

    if(
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], "../../../story_media/video/".$_SERVER['REMOTE_ADDR'].time())){ 
    It uploads? So any idea why the first statement won't?

    Thanks

    Chris

  2. #2
    Join Date
    Jul 2005
    Posts
    162
    Well, the first statement has three arguments and move_uploaded_file only accepts two. The arguments are
    1. File to be moved
    2. Where to move

    Try this:
    PHP Code:
    $file_exten ".wmv"

    $FileName $_FILES['uploadedfile']['tmp_name']; //Makes statement easier to read
    if(move_uploaded_file($FileName"../../../story_media/video/" $_SERVER['REMOTE_ADDR'].time() . $FileName $file_exten){ 
    Hope this helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles