Jump to content

Archived

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

Jurik

Linex to windows path address problems

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?

Share this post


Link to post
Share on other sites
You can fix it using this:
[code]$path = str_replace('\\','/',$path);[/code]

Share this post


Link to post
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);

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Change [code]      path = str_replace('\\','/',$path);[/code] to [code]      $target_path = str_replace('\\','/',$path);[/code]

Share this post


Link to post
Share on other sites
hhhmmm nope sorry but it didnt work, I hate to be a pain but can u still help me out?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Right I have no knowledge of Linex so i'll meantion it to me boss who knows more bout Linex than me, cheers

Share this post


Link to post
Share on other sites

×

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.