Jump to content


Photo

Linex to windows path address problems


  • Please log in to reply
14 replies to this topic

#1 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 11:22 AM

Hi guys I think im having a problem with getting my videos to save from a linex server to a windows server, the problem i'm having is with the path on the script it does not work when I put my code onto the linex server but works fine on my windows PC, at the moment im using the following path

\\\benin\\videolibrary\\

This path works fine untill I upload it to the Linex server and then the apth no longer works, does anyone know how I can resolves this problem?

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 11:38 AM

You can fix it using this:
$path = str_replace('\\','/',$path);


#3 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 01:08 PM

You can fix it using this:

$path = str_replace('\\','/',$path);


Huh sorry you have lost me do i replace

$target_path = "\\\benin\\Videolibrary\\";

with or after the above?

$path = str_replace('\\','/',$path);

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 01:11 PM

After.

#5 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 01:14 PM

hhmmm nope it still anit having it, have I put the code in right? Heres what I got

<?php
if (isset($_POST['submit'])) {
$VideoID = $_POST['VideoID'];
$Name = $_POST['Name'];
$submit = $_POST['submit'];
} else {
$VideoID = "";
$Name = "";
$submit = "";
}

$success = 0;


if ($submit == "Save" && $VideoID != NULL && $Name != NULL)
{

if ($_FILES['uploadedfile']['error'] != 0) {

$success = 0;
echo "There was an error uploading the file, please try again!";

} else {

$target_path = "\\\benin\\Videolibrary\\";

path = str_replace('\\','/',$path);

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$smell = basename( $_FILES['uploadedfile']['name']);

if (file_exists ($target_path)) {

$success = 0;
echo "The file already exists";

} else {

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ".  basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again! - This one";
}

$sql = "INSERT INTO videos (VideoID,Videofile,Name) VALUES ('" . $VideoID . "', '" . mysql_real_escape_string ($smell) . "', '" . $Name . "')";

include "conn.inc.php";

$result = mysql_query($sql) or die (mysql_error ());

if(mysql_affected_rows() == 1)
{
$success = 1;
}
else
{
echo("I'm afraid an error has been detected, please check the information entered again. If the problem persists then contact IT support");
}

}

}
}
if($success != 1) {
?>


Am not quite sure if I got the code bit u gave me right

#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 19 October 2006 - 01:15 PM

Change
      path = str_replace('\\','/',$path);
to
      $target_path = str_replace('\\','/',$path);


#7 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 01:20 PM

hhhmmm nope sorry but it didnt work, I hate to be a pain but can u still help me out?

#8 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 19 October 2006 - 01:24 PM

What, exactly, are you trying to do?

If the script is running on a Linux server, how do expect it to be able to save a file on a Windows server?

Ken

#9 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 19 October 2006 - 01:33 PM

if your on Windows or Linux, or Unix, or Mac, always use forward slashes, Windows understands them, like all the rest!

So this...

      $target_path = "\\\benin\\Videolibrary\\";
      
      path = str_replace('\\','/',$path);

      $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

Could be written like this..

      $target_path  = "./benin/Videolibrary/";
      $target_path .= basename( $_FILES['uploadedfile']['name'] );


me!

#10 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 02:03 PM

What I am trying to do is upload a file that is selected by the user, after the user clicks Save it will then put the file onto a server. The php files are running of a Linex server but the server it gets off and saves to are window servers.

#11 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 02:08 PM

if your on Windows or Linux, or Unix, or Mac, always use forward slashes, Windows understands them, like all the rest!

So this...

      $target_path = "\\\benin\\Videolibrary\\";
      
      path = str_replace('\\','/',$path);

      $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

Could be written like this..

      $target_path  = "./benin/Videolibrary/";
      $target_path .= basename( $_FILES['uploadedfile']['name'] );


me!


Nope im still getting the same error, this problem is really weird. It just dont seem to want to be fixed

#12 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 19 October 2006 - 02:14 PM

If the script is running on a Linux server the files will be saved to the Linux server. PHP running on the Linux server has no knowledge of the Windows server.

Ken

#13 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 02:18 PM

If the script is running on a Linux server the files will be saved to the Linux server. PHP running on the Linux server has no knowledge of the Windows server.

Ken


hhhmmm ok, I changed the path so that it saves the file in a folder in the same directory as the php files and I still get the same error, could this be because I am selecting files off a windows system to be saved onto a linex server? If what you say ken is true is there a way to make it knowlegable of the windows servers and thus save onto them?

#14 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 19 October 2006 - 02:26 PM

The only way for a script running on a Linux server to store files in a Windows directory is if the Windows directory is available to the Linux server via Samba or NFS.

Ken

#15 Jurik

Jurik
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 19 October 2006 - 02:35 PM

Right I have no knowledge of Linex so i'll meantion it to me boss who knows more bout Linex than me, cheers




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users