Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Upload Script Help:
Old 10-29-2005, 10:56 AM PHP Upload Script Help:
rhysgregory's Avatar
Ultra Talker

Posts: 461
Location: Cardiff, Wales, UK
Trades: 8
Hi there, i'm a bit of a newbie when it comes to php and i have this php scripts that will allow me to upload to the server, so when i'm away at work i'am able to login to my admin cpanel and upload word documents etc..

Anyways, i have set everything up i need to do to make the script work apart from when it comes to setting the permission for the ftp to allow me to upload to the server, in my php script it says:

( Remeber to chmod 777 your_upload_dir )

but i'm not sure exactly what this means and how to chmod my ftp... if anyone is able to help me out then let me know, i'd be grateful, thanks guys,

Rhys,
__________________

Please login or register to view this content. Registration is FREE
--> Free Webmaster & Seo Tools, Generators,, Articles..
rhysgregory is offline
Reply With Quote
View Public Profile Visit rhysgregory's homepage!
 
 
Register now for full access!
Old 10-29-2005, 11:09 AM My CodeL
rhysgregory's Avatar
Ultra Talker

Posts: 461
Location: Cardiff, Wales, UK
Trades: 8
<?php

<?

### Configuration ###


# What directory should the files be uploaded to ? ( Remeber to chmod 777 your_upload_dir )
$upload_directory = "uploadedfiles";

# The Max Upload Size of a file when upload to server!
$max_upload_size = "100121654"; // Set to 10 MB

# What type of files should be allowed to be uploaded ?
$allow_type = "audio/mpeg"; // This is the tag to only allow *.MP3 files to be uploaded!

# Shall the script only allow 1 file type to be uploaded ?
$allow_file_type = "10"; // Only allows 1 file to be uploaded to server!

### Font setup ###
$font = "verdana";
$font_size = "2";
$font_color = "black";

### Error Messages ###

# No file to upload
$no_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but you didn't select a file to upload";

# File is to big
$to_big_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but the file you have select is to big to be uploaded!";

# Not the correct filetype
$not_correct_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but the file you tried to upload is not valid file to upload!";

# Error to write file to upload directory
$error_write_file = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, but there has been an error processing $file_name to the
$upload_directory! Please try again later!";

# The file is already uploaded
$already_uploaded = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Sorry, the file already Exists on server!";


### Thank You Message(s) ###
$thank_you = "<b><font face=\"$font\" size=\"$font_size\" color=\"$font_color\">Thank you for your upload ($file_name)!";

####### Code Starting #######


if (!$file_name) die("$no_file");

if ($file_size > $max_upload_size) {
die("$to_big_file");
}

if ($allow_file_type == "1") {
if ($type != $allowtype) {
die("$not_correct_file");
}
}

if (file_exists("$upload_directory/$file_name")) {
die("$already_uploaded");
}

@copy($file, "$upload_directory/$file_name") or die("$error_write_file");

# EOF!
echo "<center><b>$thank_you";
?></font></font></font></font></font></font>




</center>

?>
__________________

Please login or register to view this content. Registration is FREE
--> Free Webmaster & Seo Tools, Generators,, Articles..
rhysgregory is offline
Reply With Quote
View Public Profile Visit rhysgregory's homepage!
 
Old 10-29-2005, 12:40 PM
AxE
AxE's Avatar
Skilled Talker

Posts: 62
Trades: 0
Hello,

CHMod affects the permissions of a certain file or directory.

Each permission has a number between 0 and 7. The permission groups are "Owner", "Group" and "Public".

The number for CHMod must be 4 digit, but with only 3 permission groups, so a 0 is added to the front. Why it must be? I dont know :P I just know that there always has to be a 0 there.

The permissions are:
Read = 4
Write = 2
Execute = 1

So if you wanted to grant a folder read access only, but no write or execute access for the public, but full access for Group and Owner, the CHmod would be 0774. If you wanted to grant that folder Read and Write access for the public, and full access for Owner and Group the CHMod would be 0776. If you wanted to grant Owner and Public only read access, but Group full access you would have 0474.

See the pattern?



Now, how to CHMod. You can either use the PHP function chmod(); which is the hard way to do it. The easy way is to get SmartFTP, www.smartftp.com, connect to your FTP and then locate the folder where you upload files. In the tree-view to the left right click on the folder name and click "Properties/CHMOD" and then tick all the boxes so the little text box says "777". That will grant full read,write and execute access, so that the script has permissions to upload.



Hope that makes sense, and that it solves your problem.
AxE is offline
Reply With Quote
View Public Profile
 
Old 10-29-2005, 01:39 PM
rhysgregory's Avatar
Ultra Talker

Posts: 461
Location: Cardiff, Wales, UK
Trades: 8
Thankyou very much
__________________

Please login or register to view this content. Registration is FREE
--> Free Webmaster & Seo Tools, Generators,, Articles..
rhysgregory is offline
Reply With Quote
View Public Profile Visit rhysgregory's homepage!
 
Reply     « Reply to PHP Upload Script Help:
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38256 seconds with 12 queries