Birden sayfalarından bir dizin PHP yükleme görüntü

2 Cevap php

Siteme görüntüleri yükleyerek bir komut dosyası var, yerel olarak çalışır (hatta henüz web sunucu üzerinde test değil) ama sorun ben bir merkez için resim yüklemek için nasıl anlamaya değil ki Konumu ne olursa olsun komut çalıştırmak nerede.

Örneğin benim site yapısı bu gibi görünüyor:

/ROOT/
   /IMAGES/
   /USER/
      upload.php
      /IMAGES/
      /ADS/
         upload.php
         /IMAGES/
      /COUPONS/
         upload.php
         /IMAGES/

Right now the different upload.php files inherit from another php file that has the uploading script. Inside the script the line that sets the upload path looks like this $newname = "images/".$image_name;. That line is why I have an "images" directory under User and one under ADs and one under Coupons. What I want is to be able to have my script upload all images to the /IMAGES/ directory under the /ROOT/ directory, but I can only figure out how to make the path go up levels (using "../") rather than start at the root and go down. How can I get it to always upload to the /ROOT/IMAGES/ directory?

2 Cevap

Bu çalışması gerekir

$newname = $_SERVER['DOCUMENT_ROOT']."/images/".$image_name;

Kullanın:

$path = $_SERVER['DOCUMENT_ROOT'];
$path .= '/images/';