Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.