Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Upload recv Error

Status
Not open for further replies.

nat1967

Technical User
Feb 13, 2001
287
US
oh... i am up against the wall and sliding fast....

all i am trying to do is upload a file to a directory on the webserver. (i'd love to email to me also but thats asking to much) :)

here is my code so far:

<html>
<head>
<title>Listing 9.14 A file upload script</title>
</head>
<body>
<h1>File Upload Results</h1>
<?php
$file_dir = &quot;/form&quot;;

foreach($_FILES as $file_name => $file_array) {
print &quot;path: &quot;.$file_array['tmp_name'].&quot;<br>\n&quot;;
print &quot;name: &quot;.$file_array['name'].&quot;<br>\n&quot;;
print &quot;type: &quot;.$file_array['type'].&quot;<br>\n&quot;;
print &quot;size: &quot;.$file_array['size'].&quot;<br>\n&quot;;
print &quot;file dir: &quot;.$file_dir.&quot;<br>\n&quot;;

if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'],
&quot;$file_dir/$file_array[name]&quot;) or die (&quot;Couldn't copy&quot;);
print &quot;file was moved!<br><br>&quot;;

}
}
?>
</html>
************************************

needless to say, it doesnt work. i get an error:

path: /tmp/php00010213aa
name: yourship.jpg
type: image/pjpeg
size: 4224
file dir: /form

Warning: move_uploaded_file(/form/yourship.jpg): failed to open stream: No such file or directory in /local/vips/home0/nathan/skylineprints.com/listing9.14.php on line 19

Warning: move_uploaded_file(): Unable to move '/tmp/php00010213aa' to '/form/yourship.jpg' in /local/vips/home0/nathan/skylineprints.com/listing9.14.php on line 19
Couldn't copy

i am very new to PHP but need someone's help. I am very lost.... :-(



Have A Great Day!!!, [bigglasses]

Nathan
Software Testing Lead
 
I'm not sure here,

but perhaps it should be:

$file_dir = &quot;form/&quot;;

and not:

$file_dir = &quot;/form&quot;;

?

I have a feeling that the preceeding / is causing PHP to read the base directory path and not your relative one?

Or I may be talking total nonsence - still give it a try and see :)

Regards
-Colin
 
well guys and gals,

an all nighter paid off...

i figured out the deal. i was making an assumption that the path for my directory was implied so i could just reference the sub directory. i was WRONG!!! it works like that is other coding but not here... hmmm...

anyway, i changed the following line and all is good now. i must reference the entire string to my targt directory.

$file_dir = &quot;/local/vips/home0/nathan/skylineprints.com/form&quot;;

now maybe i'll stay up all day and figure out how to email the attachment.... :)




Have A Great Day!!!, [bigglasses]

Nathan
Software Testing Lead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top