Problems opening file + str_replace
| From: | (Grusell) | Date: | Mon, 19 May 2003 14:28:43 +0000 |
| Subject: | Problems opening file + str_replace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-148166@lists.php.net to get a copy of this message | ||
Hi!
Let me describe my problem:
I have this form where I browse for files (powerpoints) on my computer. I
select a file, click the open-button and I go to another page that is
supposed to open my powerpoint-file (in_pp2.php).
The thing is that I need to str_replace some parts of the filename.
It usually comes out lookin like this
file///D://my_powerpoint.ppt
but needs to be D:/my_powerpoint.ppt, in order for me to open it.
Therefore I have a str_replace that should take care of the problem, but
it still won't work for some reason.
I have tested the str_replace function when I manually set $path =
file:///D://my_powerpoint.php, and then it does the correct replacing. But
why won't it replace the characters when I'm sending the path through this
form
Any ideas, help would be greatly appreciated, since this problem has been
bugging me for two days now.
Thanks!
in_pp.php
<?
require("dbmanager.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Browse powerpoint</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style2.css" rel="STYLESHEET" type="text/css">
</head>
<body>
<form name="sendFile" method="post" action="in_pp2.php"
enctype="multipart/form-data">
<input type="hidden" name="path"/>
<input type="hidden" name="isubmit" value="Open"/>
<input type="file" size="15" name="file"
class="button"/>
<input type="button" value="Open" class="button"
OnClick="this.form.path.value = this.form.file.value; this.form.submit()">
</form>
</body>
</html>
in_pp2.php
<?php
$path= $_POST["path"];
$path = str_replace("file:///","", $path);
$path = str_replace("://",":/", $path);
header("Location: $path");
exit;
?>