Make WordPress Core

Changeset 434


Ignore:
Timestamp:
10/08/2003 05:28:25 PM (23 years ago)
Author:
emc3
Message:

Added workaround for move_uploaded_file() problems in some server setups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/b2upload.php

    r399 r434  
    1313?><html>
    1414<head>
    15 <title>b2 > upload images/files</title>
     15<title>WordPress :: upload images/files</title>
    1616<link rel="stylesheet" href="<?php echo $b2inc; ?>/b2.css" type="text/css">
    1717<style type="text/css">
     
    167167        $i = explode(" ",$fileupload_allowedtypes);
    168168        $i = implode(", ",array_slice($i, 1, count($i)-2));
    169         move_uploaded_file($img1, $pathtofile2)
    170          or die("Couldn't Upload Your File to $pathtofile2.");
     169        $moved = move_uploaded_file($img1, $pathtofile2);
     170        // if move_uploaded_file() fails, try copy()
     171        if (!$moved) {
     172            $moved = copy($img1, $pathtofile2);
     173        }
     174        if (!$moved)
     175            die("Couldn't Upload Your File to $pathtofile2.");
    171176   
    172177    // duplicate-renaming function contributed by Gary Lawrence Murphy
     
    197202
    198203    if (!strlen($imgalt)) {
    199         move_uploaded_file($img1, $pathtofile) //Path to your images directory, chmod the dir to 777
    200          or die("Couldn't Upload Your File to $pathtofile.");
     204        @$moved = move_uploaded_file($img1, $pathtofile); //Path to your images directory, chmod the dir to 777
     205        // move_uploaded_file() can fail if open_basedir in PHP.INI doesn't
     206        // include your tmp directory. Try copy instead?
     207        if(!moved) {
     208            $moved = copy($img1, $pathtofile);
     209        }
     210        // Still couldn't get it. Give up.
     211        if (!moved)
     212            die("Couldn't Upload Your File to $pathtofile.");
    201213    } else {
    202214        rename($img1, $pathtofile)
Note: See TracChangeset for help on using the changeset viewer.