Hello, When I create a file or folder, my server always has the file/folder to the CMOD setting of 'CHMOD 744'. I've uploaded this image and this is the result becuase the script creates a folder and the server automatically changes it to 'CHMOD 744'. If you can give me intructions in how I can change the automatic file creation CHMOD folder value, please tell me...I'll be changing it so the server automatically creates folders with the CHMOD '755'. Any intructions is appreciated. Thanks.
I don't think you have a server problem. I think you have a configuration issue with your script. If I enter the URL www . flickcabin.com/ sessions/ , crippled in this post with extra spaces, I can browse your directory and see all your images. Normally chmoding the image directory to 777 is all you need. All images can then be viewed with a chmod of 644 and sometimes less. Unless your hosting is dedicated or vps you can not change the server default. You can modify your upload script to chmod it after uploading if you know how. At least you can on most servers.
You dont have to change it from server settings..You'll have to modify your script so if a user uploads a file it automatically changes it's chmod to 777 Saad
I'm on a managed dedicated server...I do have root access. I have no clue how to make it CHMOD automatically after upload. - I'd rather do this on the server side. Anyways, yeah you can access: flickcabin.com/sessions/ - it's just when I upload a file it gives me a 403 error, becuase that specific directory is CHMOD 744.
I looked at the base site. I realize now that you are actually creating a new directory for each user to store their images in. It may be possible for you to change the default settings for the mkdir command since you are on a dedi. If you want to go that route you are going to have to ask support where your dedi is located. I went through something like this a couple of years ago. When your script invokes the mkdir $newdir (or whatever the $var is) command all you have to add after that is chmod $newdir XXX; and let the script continue. This is a much safer workaround than what you are considering. For the exact syntax you can refer to a post I made over at the siteframe forum some time back (same user name as here, I think).
Thank you for the help, but I have no clue where to put all that. Heres my code: <?php session_start(); if(is_dir("sessions/" . sha1(session_id())) === false) { mkdir("sessions/" . sha1(session_id())); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Flick Cabin - File Uploaded!</title> <meta name="description" content="FlickCabin is a fast and reliable image hosting website. Our speed and interface unites to bring you one of the best look and fastest image hostings around!"> <meta name="keywords" content="Flick,Cabin,Image,Host,Hosting,Photos,Web,Design"> <link rel="stylesheet" href="base.css" type="text/css" media="all" /> </head> <body> <div id="wrapper"> <div id="header"> <a href="/"><img src="images/logo.gif" alt="" /></a> <script language="JavaScript" type="text/javascript" src="adbanner.js"></script><br /><br /> </div> <div id="satisfied"></div> <div id="content"> <div id="discription"> <div class="left-corner"></div> <p> <strong>Welcome to Flick Cabin!</strong><br /> Welcome to FlickCabin, the image host that is right for you. You may ask <span>why</span>? Well simply because we persue the simplicity and straight forward user experience that any designer has looked in an image host. </p> <p> Here at FlickCabin, we understand that not many users have the time nor patience to upload their image. Some hosts are bloated with advertisements, others simply don't work. </p> <p> We have looked all over all the negatives and build you the ultimate tool for your uploading needs. If you find something that can be improved, please <a href="contact.php">Contact Us</a>!<br /> </p><p>Copyright <b>Flick Cabin</b> 2006<br /> <p><script language="JavaScript" type="text/javascript" src="adbannerfooter.js"></script> <div class="left-corner-b"></div><div class="right-corner-b"></div> </div> <div id="upload"> <div class="right-corner"></div> <p> <?php if(isset($_POST['ok'])) { $filetypes = array("jpeg", "jpg", "gif", "png", "tif", "tiff", "pjpeg", "psd"); if(!$_FILES['image']) { ?><span id="title" class="title-red">Error</span><p /> <div style="margin: 10px" id="error" class="error"><a href="index.php" />< Back</a><p /> Please select an image to upload.</div><? die(); } elseif($_FILES['image']['size'] > 10485760) { ?><span id="title" class="title-red">Error</span><p /> <div style="margin: 10px" id="error" class="error"><a href="index.php" />< Back</a><p /> Your image exceeds 10 megabytes.</div><? die(); } $safe = false; foreach ($filetypes as $filetype) { if("image/" . $filetype == $_FILES['image']['type']) { $safe = true; } } if($safe === false) { ?><span id="title" class="title-red">Error</span><p /> <div style="margin: 10px" id="error" class="error"><a href="index.php" />< Back</a><p /> Invalid filetype. Please note the information on the previous page.</div><? die(); } else { move_uploaded_file($_FILES['image']['tmp_name'], "sessions/" . sha1(session_id()) . "/" . $_FILES['image'] ['name']); $imagepath = "http://www.flickcabin.com/sessions/" . sha1(session_id()) . "/" . $_FILES['image']['name']; $siteurl = "http://www.flickcabin.com/"; $dimensions = getimagesize("sessions/" . sha1(session_id()) . "/" . $_FILES['image']['name']); ?> <strong>Almost there...just the format for your flick!</strong><br /> <img src="images/3.gif" alt="" /><br /> <b>UpperCase BBCode:</b><br /> <input type="text" class="file" onclick="highlight(this)" style="width: 300px" value="[URL=<?=$siteurl?>][IMG]<?=$imagepath?>[/IMG][/URL]" /><br /> <b>LowerCase BBCode:</b><br /> <input type="text" class="file" onclick="highlight(this)" style="width: 300px" value="[url=<?=$siteurl?>][img=<?=$imagepath?>[/url]" /><br /> <b>Direct Link:</b> (<a href="<?=$imagepath?>">Link</a>)<br /> <input type="text" class="file-last" onclick="highlight(this)" style="width: 300px" value="<?=$imagepath?>"> <? } } ?><p><img src="images/step_3.gif" /><br /><b>Link back to us : HTML</b><br /><input type="text" size="60" onclick="this.focus();this.select()" class="file" value='<a href="http://www.flickcabin.com">Free Image Hosting</a> " />' /><br/> <b>Link back to us: BBCode<br /></b> <input type="text" size="60" class="file" onclick="this.focus();this.select()" value='[URL="http://www.flickcabin.com"]Free Image Hosting[/URL] " />' /> <div class="left-corner-b"></div><div class="right-corner-b"></div> </div> <br clear="all" /> </div> <div id="footer"> </div> </div> </body> </html> PHP: If anything turns to worse, I'll see if I can get a coder to fix it.
It is right up there at the top of your script. I think I have the proper syntax. I am not that good with php. Add the line below that is in red to your script: Suggest you make a backup copy of the script before making the change. I used 755 for the chmod. You can change that to any number you like. Copy it from this forum to notepad to kill any added fromating and then to your script. Be sure word wrap is OFF if you use notepad to open your script. I suggest you download a copy of notepad2 or other pure text editor for working with scripts. Be sure to let me know if it works or not. Edit: test it with 777 if 755 does not work.
Hello, I added that bit of coding, but I'm still getting the same error: Parse error: syntax error, unexpected ',' in /home/flick/public_html/process.php on line 4 Code: Thanks.
Try single quotes or no quotes inside the chmod statement. Beyond that I don't think I have anything to offer.
Hello, It didn't work, it came up with the same error. - Should I go back to that server option? Make it so that when new files are created their chmod settings are already 0777 or either 755. - I think I'll contact my server manager. Thanks for your help though, I do really appreciate it. +Rep