>I'm trying to upload files from my PC to my website.  The code is a little
>nuts, but it's all I got to work locally, butonce I take the code to the web
>I get this message.  Can anyone tell me what I'm doing wrong?
>
>I'm trying to upload a file, strip all the information so as to just use the
>name of the file to store in the database.  I'm using explode and array_pop
>for this, but I'm sure there's a better way.  The problem seems to be in
>writing the file to the web server.  I changed the permissions on the
>directories, so I don't think that's the problem.  Please help.
>
>Thanks,
>
>Brian
>
>---------------ERROR FROM WEB SERVER---------------
>
>Warning: Unable to open 'D:\harley\images\DSC00447.jpg' for reading: No such
>file or directory in /public_html/harleyuppic_fsp.php on line 19

Do a trial with the same code below but put a sleep(120) right before the
copy() line, and have a window open on the directory D:\harly\images\ and
hit F5 a lot to refresh it.  See if the file DSC00447.jpg (or whatever)
appears before you try to copy it.  If not, why not?

I'm also getting more than a bit nervous about this harleyuppic_fsp.php on
my second read-through...

Are you trying to do a header("Location: ") or something before you deal
with the uploaded file?  You can't do that.  PHP is gonna nuke the file that
uploaded as soon as the script that "catches" it ends.  You *must* copy that
file or otherwise preserve its contents within that script or it's *GONE*.

>
>
>---------------PHP CODE----------------
>
><body>
>
><?php
>
>if ($submit) {
>
>  $db = mysql_connect("localhost", "user", "password")
> or die("Could not connect to databse.");
>  mysql_select_db("database") or
> die("Cannot select database");
>
>$hope2 = explode("\\",$imagefile);
>$hope4 = array_pop($hope2);
>
>copy ($imagefile, "\\public_html\\images\\".$hope4);
>
>mysql_query ("insert into imagefiles (img) values ('$hope4')");
>
>  $sql = "select img from imagefiles";
>  $result = mysql_query($sql) or
> die( mysql_error() );
>
>$number_cols = mysql_num_fields($result);
>
>//layout table header
>echo "<table border = 1>\n";
>echo "<tr align=center>\n";
>for ($i=0; $i<$number_cols; $i++)
>{
> echo "<th>" . mysql_field_name($result, $i). "</th>\n";
>}
>echo "</tr>\n";//end table header
>
>//layout table body
>
>while ($row = mysql_fetch_row($result))
>{
> echo "<tr align=left>\n";
> for ($i=0; $i<$number_cols; $i++)
> {
>  echo "<td>";
>   {echo "<img src='$row[$i]'>";}
>   {echo $row[$i];}
>  echo "</td>\n";
> }
> echo "</tr>\n";
>}
>
>echo "</table>";
>
>
>} else {
>
>?>
>
><form method="post" action="<?php echo $PHP_SELF?>">
><form enctype="multipart/form-data" action="admin_product.php" method
>="post">

For starters, you shouldn't have two nested FORM tags.  That won't work.

I don't even know if admin_product.php or whatever $PHP_SELF is will end up
being the page loaded.

I'm guessing from the error message that it's $PHP_SELF which is
harleyuppinc.php, but who knows?

><input type=file name="imagefile">
><br>
><input type="Submit" name="submit" value="Add picture to database">
></form>
></form>
>
>
><?php
>} // end if
>
>?>
></body>

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to