473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

upload script creating files with CHMOD 600

5
Hi im trying to get images to upload into a directory on my server but i cannot get them to upload as chmod 755 so that they are viewable can anyone help?

[PHP]<?php include"connftp.php"; ?>

<? if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
&& ($_FILES["file"]["size"] < 100000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"../upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>[/PHP]
Feb 17 '07 #1
7 5164
xwero
99
after you move the file you can use chmod.

[PHP]chmod('path/to/file/filename.ext',0755);[/PHP]
Feb 18 '07 #2
xwero
99

[PHP]

<? if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
&& ($_FILES["file"]["size"] < 100000))

?>[/PHP]
if you only need to upload images it's best to check with getimagesize this gives you php fetched mime type instead of the browser fetched mime type which can not always be trusted. Contrary to it's name it doesn't get the file size.

[PHP]

<?
$imagesize = getimagesize($_FILES["file"]);
if (($imagesize['mime'] == "image/gif")
|| ($imagesize['mime'] == "image/jpeg")
|| ($imagesize['mime'] == "image/pjpeg") // don't forget the IE mime type
&& ($_FILES["file"]["size"] < 100000))

?>[/PHP]
Feb 18 '07 #3
hadge
5
if you only need to upload images it's best to check with getimagesize this gives you php fetched mime type instead of the browser fetched mime type which can not always be trusted. Contrary to it's name it doesn't get the file size.

[PHP]

<?
$imagesize = getimagesize($_FILES["file"]);
if (($imagesize['mime'] == "image/gif")
|| ($imagesize['mime'] == "image/jpeg")
|| ($imagesize['mime'] == "image/pjpeg") // don't forget the IE mime type
&& ($_FILES["file"]["size"] < 100000))

?>[/PHP]
I can use the CHMOD script, but only to write individual file names, so if i use that i need to be able encompass the file name that is being uploaded into the script. ie
"/www/var/html/"$_files
But i havent been able to get it working :( with the embedded string
Feb 18 '07 #4
xwero
99
Do you mean you want to upload multiple files?
Feb 18 '07 #5
hadge
5
Do you mean you want to upload multiple files?

No i can specify the file (but i have to know what its called) meaning i will need to run CHMOD after the upload.

But what i want it to do is chmod it as its being uploaded (so using the string for the file name)
Feb 18 '07 #6
xwero
99
It's not possible to set the chmod during the upload because php uploads the file to a temporary file.
Feb 18 '07 #7
hadge
5
It's not possible to set the chmod during the upload because php uploads the file to a temporary file.
Thanks Xwero
Feb 18 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Philippe Lemmerling | last post by:
I have a question concerning security of my file upload script. I'm using the php upload routines (move_uploaded_file,...) and variables ($_FILES) to upload images to a webdirectory. Everything...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
4
by: pdav | last post by:
Hi! Is there any solution to create a directory with one script with mkdir(), and then write a file (or move an uploaded file) in this directory with another script? The problem is, that the...
4
by: Ian N | last post by:
Hi i'm having a problem with file permissions of upload, they appear to be being set to only readable by the administrator, so anyone browsing the site gets a 403 forbidden error when they try and...
7
by: luigi7up | last post by:
Weird problem I have, really :) I wrote a script that uploads files to /user_upload/ directory. On localhost version of my site everything works just fine. I mean files are uploaded well. With...
0
by: foekall | last post by:
I used this script and test on my hosting. Evertimes appear "change permission to 777 failed. ". So, how to solve this error. Please kindly check for me and teach me. <?php $MAX_SIZE =...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
5
by: petershaman | last post by:
Hi I have a gorgeous flash image gallery, it would work perfectly fine but there's a small problem I can't upload anything thru it's upload script, since I'm getting an error 403. It's so because...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.