View Full Version : $user = $_SERVER['REMOTE_USER'];

07-31-2008, 06:44 PM
Hey All,
I'm trying to implement a Java Upload Applet(RadUpload) which allows upload of entire directories at once, and in the case of images also re-sizes the images PRIOR to uploading. I have gotten it up and running on my development server (WAMP Stack), however I am having difficulty on the production server (same stack) which I believe is owed to the fact that I have employed .htaccess and .htpasswd user authentication on that server.

In context -- a script from within a module deep within http://localhost/crm/index.php calls http://localhost/crm/applet.php, which then calls http://localhost/crm/upload.php which then moves the uploaded files to the desired -- dynamically created directory.
The following configuration in applet.php works on the development server
<param name = "url" value = "http://localhost/crm/upload.php">However logged in to the crm on the production server with applet.php configured as follows...
<param name = "url" value = "http://my.ip.address.no/crm/upload.php">...having provided the .htpasswd credentials for access to http://my.ip.address.no/crm/index.php -- and navigating to the module, the call back to http://my.ip.address.no/crm/applet.php succeeds while the subsequent call to http://my.ip.address.no/crm/upload.php throws the following error:
Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
Apache/2.0.55 (Win32) PHP/5.1.2 Server at *.*.*.*(my ip address) Port 80 While upload.php looks basically like this:
$img_dir= $_POST['img_dir'];

$file = $_FILES['userfile'];
$k = count($file['name']);
for($i=0 ; $i < $k ; $i++){
$shortName = split('/',urldecode($file['name'][$i]));
if(isset($save_path) && $save_path!=""){
$name = $shortName;
move_uploaded_file($file['tmp_name'][$i], $save_path . $name[count($name)-1]);
Why would the call to upload.php FROM applet.php (same dir) require authentication (presumedly owing to use of .htaccess and .htpaswd) while the initial call to applet.php from within the crm module does not?
Would it be possible --pragmatically -- to pass the "credentials" back to .htpasswd employing something like $_SERVER['REMOTE_USER']; and or $_SERVER['PHP_AUTH_USER'] within upload.php ???:confused:???