Jump to content

File not loading


ded

Recommended Posts

The picture is not loading to the folder....the following error appears:

Error: Photo did not upload properly.  Try again.

 

     	     
echo "<form action=\"post.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\">";
echo "File to Upload:<input name=\"filename\" type=\"file\"><br><br>";
echo "<input type=\"submit\">";
echo "</form></center>";

 

 

$uploaddir = '../../pictures/';
$filename = $_FILES['filename']['name'];
$path = $uploaddir . $filename;
echo '<pre>';
if (move_uploaded_file($_FILES['filename']['tmp_name'], $path)) { 
      echo "Photo has been uploaded to database"; 
   } else { 
      echo "Error: Photo did not upload properly.  Try again."; 
   } 
print "</pre>";

 

Any help would be great.....

 

 

Regards,

DED

Link to comment
https://forums.phpfreaks.com/topic/129319-file-not-loading/
Share on other sites

Excellent.....thank you.

 

I am getting this:

 

 

Notice: Undefined index: filename in /home/site1/public_html/site2/admin/homepage/post.php on line 13

 

Notice:  Undefined index:  filename in /home/site1/public_html/site2/admin/homepage/post.php on line 16

Error: Photo did not upload properly.  Try again.

 

Link to comment
https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670435
Share on other sites

You need

enctype="multipart/form-data"

in your <form> tag:

<?php
echo '<form action="post.php" method="post" enctype="multipart/form-data">';
echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000">';
echo 'File to Upload:<input name="filename" type="file"><br><br>';
echo '<input name="submit" type="submit">';
echo '</form></center>';
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670442
Share on other sites

Your getting me there.....It finally recognizes the filename, but now I am receiving the following:

 

Warning:  move_uploaded_file(http://www.website.com/pictures/image.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections. in /home/site1/public_html/site2/admin/homepage/post.php on line 16

 

Warning:  move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpd8e2UR' to 'http://www.website.com/pictures/image.jpg' in /home/site1/public_html/site2/admin/homepage/post.php on line 16

 

Error: Photo did not upload properly.  Try again.  ../../pictures/image.jpg

 

I have not a clue what this all means.....

 

 

Thanks again to everyone for the help.

 

 

DED

Link to comment
https://forums.phpfreaks.com/topic/129319-file-not-loading/#findComment-670452
Share on other sites

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.