Jump to content

Linex to windows path address problems


Jurik

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/24431-linex-to-windows-path-address-problems/
Share on other sites

[quote author=Daniel0 link=topic=112005.msg454280#msg454280 date=1161257894]
You can fix it using this:
[code]$path = str_replace('\\','/',$path);[/code]
[/quote]

Huh sorry you have lost me do i replace

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

with or after the above?

$path = str_replace('\\','/',$path);
hhmmm nope it still anit having it, have I put the code in right? Heres what I got

[quote]<?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) {
?>[/quote]

Am not quite sure if I got the code bit u gave me right
if your on Windows or Linux, or Unix, or Mac, always use forward slashes, Windows understands them, like all the rest!

So this...

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

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

Could be written like this..

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


me!
[quote author=printf link=topic=112005.msg454346#msg454346 date=1161264839]
if your on Windows or Linux, or Unix, or Mac, always use forward slashes, Windows understands them, like all the rest!

So this...

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

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

Could be written like this..

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


me!
[/quote]

Nope im still getting the same error, this problem is really weird. It just dont seem to want to be fixed
[quote author=kenrbnsn link=topic=112005.msg454385#msg454385 date=1161267270]
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
[/quote]

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.