Jump to content

Upload using move_uploaded_file


waverider303

Recommended Posts

When i use the move_uploaded_file to upload images I think it is uploading using ASCII mode to transfer. Because when I goto view the image that I uploaded I get an error. Im using shared hosting from Doteasy.com do I need to change information in the php.ini file to make it upload in binary?

Link to comment
https://forums.phpfreaks.com/topic/151668-upload-using-move_uploaded_file/
Share on other sites

$small_file_name = $_FILES['small']['name'];
$small_tmp_name = $_FILES['small']['tmp_name'];
$destination = '../webisode_images';

if(!empty($small_file_name)) {
		if(move_uploaded_file($small_tmp_name,"$destination/$small_file_name")) {
			$sql .= ", small_file_name='$small_file_name' ";
		}
	}

<?php
					$sql = "SELECT * FROM webisodes WHERE season=1";
					$result =mysql_query($sql);
					while ($row=mysql_fetch_assoc($result)){
						$title=$row['title'];
						$description=$row['description'];
						$video_large=$row['video_large'];
						$episode=$row['episode'];
						$small_file_name=$row['small_file_name'];
						$season=$row['season'];
					}
				?>
                    <a href="webisodes.php?season=<?=$season?>"><img src="<?=$small_file_name" title="<?=$title?>" alt="<?=$title?>" height="150px" width="150px" /></a>

 

What the problem is... is that if you goto the url that the file was uploaded i get an 404 error from my hosting company saying that the file is not there. When I FTP into my account I see the files there.

 

A 404 error page?

 

 

Pretty sure your path is wrong then.

 

 

Oh hrmmm....  Wonder if it is this:

 

 

"<?=$small_file_name"

 

 

You missed the closing ?>.

 

 

 

It's bad practice to use short tags by the way since they're sometimes disabled on some servers.

Ok here is the link I goto and get the error

 

This one was uploaded with the form:  Form Uploaded

 

This one was uploaded using FTP:      FTP Uploaded

 

 

I know ones a jpg and the other is a png but if I used the form to do the png it would still do the same. Also it says i need a index.html page?

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.