Jump to content

move_uploaded_file permitions help


nezbo

Recommended Posts

Hi all

 

I am uploading a file (image) and every time i upload one, it gives it the permitions of 0500 and the image is not viewable on the site.

 

is there any way to change the permitions on the file as i upload it?

 

Here is my code to far:

 

<?php
$dir = "./rideImages/" . $_REQUEST['rideid'];
if (!is_dir($dir))
{
	mkdir ("./rideImages/" . $_REQUEST['rideid'] , 0777);
}
if ($_FILES["file1"]["size"] >= 250000)
{
	echo  "<div align='center'>" . $_FILES["file1"]["name"] . " is to large can not be uploaded.</div>";
}	
else if ($_FILES["file1"]["type"] != "image/pjpeg")
{
	echo  "<div align='center'>" . $_FILES["file1"]["name"] . " is not a .jpg file type and can not be uploaded.</div>b";
}
else if ($_FILES["file1"]["type"] != "image/pjpeg")
{
	echo  "<div align='center'>" . $_FILES["file1"]["name"] . " is not a .jpg file type and can not be uploaded.</div>b";
}		
else if (move_uploaded_file($_FILES["file1"]["tmp_name"],"./rideImages/" . $_REQUEST['rideid'] . "/" . $_FILES["file1"]["name"]))
{
	$theName = $_FILES["file1"]["name"];
	$theDir = $dir . "/" . $_FILES["file1"]["name"];
	$sql = "INSERT INTO rideimages (rideID, imagePath, userID) VALUES ('" . $_REQUEST['rideid'] . "', '".$theDir."', '".$_COOKIE['user']."')";
	if (!@mysql_query($sql,$con))
	{
		die('Error : ' . mysql_error());
	}

	echo "<div align='center'><font size=\"1\" color=\"red\"><strong>File Name : " . $_FILES["file1"]["name"] . "<br>File Type : " . $_FILES["file1"]["type"] . "<br> File Size : " . ($_FILES["file1"]["size"]) / 1024 . "kb<br>Image uploaded.</strong></font></div>";
}
}

Link to comment
https://forums.phpfreaks.com/topic/117165-move_uploaded_file-permitions-help/
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.