View previous topic :: View next topic |
Author |
Message |
Pookie -
Joined: 05 Jan 2005 Posts: 60 Location: Citrus Heights, CA
|
Posted: Wed Feb 01, 2006 7:52 am Post subject: php uploading |
|
|
i dont think i got this code completely setup right. i posted the code to a blank webpage until i got it to work and i browsed for a file and click upload file and got the message "No file selected or file is too big" what am i doing wrong? i seleted a file when i browsed for it and it cant be too big because its a small picture file. heres the code im using
form.php:
<!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>
<title>Upload a File</title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="3000048576" />
Select a File: <input type="file" name="uploadFile" /><br >
<input type="submit" name="Submit" value="Upload File" />
</form>
</body>
</html>
upload.php:
<?php
// Set the path to store the uploaded file
// Make sure the directory is writable (chmod to 777)
$path = 'E:\Program Files\Abyss Web Server\htdocs';
// Get POST data
$maxFileSize = $_POST['3mb'];
$file = $_FILES['uploadFile'];
// Was the file uploaded?
if (! is_uploaded_file($file['tmp_name'])) {
// No. print an error
die('No file selected or file is too big.');
}
// Check the size of the file
if ($file['size'] > $maxFileSize) {
die('File is too big.');
}
// Move the file
if (! move_uploaded_file($file['tmp_name'],$path.$file['name'])) {
// Unable to move the file
die('Error moving the file.');
}
echo 'File Uploaded Successfully.';
?> _________________ ~TRU~ |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Wed Feb 01, 2006 8:40 am Post subject: |
|
|
In your php.ini there is an option to turn the uploading size up. The default size is 2MB. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
|
Pookie -
Joined: 05 Jan 2005 Posts: 60 Location: Citrus Heights, CA
|
Posted: Wed Feb 01, 2006 8:56 am Post subject: |
|
|
i increased it to 20mb, but im getting the same thing. and this writting is showing under the browse and upload buttons and i know that code writting isn't suppose to be showing lol, heres wat it says:
$maxFileSize) { die('File is too big.'); } // Move the file if (! move_uploaded_file($file['E:\PHP\uploadtemp'],$path.$file['name'])) { // Unable to move the file die('Error moving the file.'); } echo 'File Uploaded Successfully.'; ?> _________________ ~TRU~ |
|
Back to top |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Wed Feb 01, 2006 10:47 am Post subject: Re: php uploading |
|
|
Your problem is with the following line:
Code: | $maxFileSize = $_POST['3mb']; |
The variable about should correspond to the following text field in form.php:
Code: | <input type="hidden" name="MAX_FILE_SIZE" value="3000048576" /> |
so that line of code should read:
Code: | $maxFileSize = $_POST['MAX_FILE_SIZE']; |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
|
Pookie -
Joined: 05 Jan 2005 Posts: 60 Location: Citrus Heights, CA
|
Posted: Wed Feb 01, 2006 6:09 pm Post subject: |
|
|
ok i corrected that, and im still getting the *File not selected or too big* error!
im using small pictures to see if this works and these pictures are about 5kb really small. i dont know what else to do, i even corrected my PHP.INI file to the right default uploading size _________________ ~TRU~ |
|
Back to top |
|
|
Pookie -
Joined: 05 Jan 2005 Posts: 60 Location: Citrus Heights, CA
|
|
Back to top |
|
|
Pookie -
Joined: 05 Jan 2005 Posts: 60 Location: Citrus Heights, CA
|
Posted: Tue Feb 07, 2006 9:33 pm Post subject: |
|
|
i think im changing something inside the code that im not suppose to. i need a code typed in black and red tellin me to change only whats typed in red or somethin lol. heres what im getting now...
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in E:\Program Files\Abyss Web Server\htdocs\upload.php on line 3
Parse error: syntax error, unexpected T_STRING in E:\Program Files\Abyss Web Server\htdocs\upload.php on line 39
Heres my upload.php code as i have it setup now
<?php
// Set the path to store the uploaded file
// Make sure the directory is writable (chmod to 777)
$path = 'E:/Program_Files/Abyss_Web_Server/htdocs';
// Get POST data
$maxFileSize = $_POST['MAX_FILE_SIZE'];
$file = $_FILES['uploadFile'];
// Was the file uploaded?
if (! is_uploaded_file($file['E:Program_FilesAbyss_Web_Serverhtdocs'])) {
// No. print an error
die('No file selected or file is too big.');
}
// Check the size of the file
if ($file['size'] > $maxFileSize) {
die('File is too big.');
}
// Move the file
if (! move_uploaded_file($file['E:/Program_Files/Abyss_Web_Server/htdocs'],$path.$file['name'])) {
// Unable to move the file
die('Error moving the file.');
}
echo 'File Uploaded Successfully.';
?>
anybody see what im doing wrong? and i have no idea where to put the info for what kinda file i wanna allow to upload.[/b] _________________ ~TRU~ |
|
Back to top |
|
|
Pookie -
Joined: 05 Jan 2005 Posts: 60 Location: Citrus Heights, CA
|
Posted: Tue Feb 07, 2006 11:36 pm Post subject: |
|
|
ok nevermind i got it, i had my uploading path setup wrong. Thankx anyway :-) _________________ ~TRU~ |
|
Back to top |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
|
Back to top |
|
|
Pookie -
Joined: 05 Jan 2005 Posts: 60 Location: Citrus Heights, CA
|
Posted: Wed Feb 08, 2006 12:16 am Post subject: |
|
|
Thankx,
now that i got it workin, people can upload pics to a folder in my server directory and its showing up fine on my computer. but when they go to where its uploaded on from the internet as i did, its showin up as links (the index of that folder). is there a way to make it to where the pics will show up as thumbnails on a webpage?. sound like i need to setup .asp, but dont know where to find a free 1 _________________ ~TRU~ |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Wed Apr 12, 2006 2:04 pm Post subject: |
|
|
www.mrwiseone.com/proxy/
You enter the address and configure your desired settings and then you press Browse and you receive a blank page. Whats wrong with it?
Code: | ;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
upload_max_filesize = *My value in Megabytes* |
I've read over http://uk2.php.net/manual/en/features.file-upload.php and no results. :cry: |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Wed Apr 12, 2006 2:11 pm Post subject: |
|
|
You forgot to edit "post_max_size". The reason why you need to set this
, is because your Upload script uses the POST method. Do this!
php.ini
Code: | post_max_size = 20M
|
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Wed Apr 12, 2006 2:28 pm Post subject: |
|
|
It did not work :( |
|
Back to top |
|
|
ozzy214 -
Joined: 31 Mar 2006 Posts: 66
|
Posted: Thu Apr 13, 2006 12:23 am Post subject: |
|
|
I got an easier way. Celeron dude makes a nice uploading script. Very professional and only 25 dollars. You have admin control and can allow/disallow public uploading. A lot of other nice nifty features. I was thinking of it so my members can post funny flash and mpeg movies...
http://www.celerondude.com/ |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Thu Apr 13, 2006 2:06 am Post subject: |
|
|
ozzy214 wrote: | I got an easier way. Celeron dude makes a nice uploading script. Very professional and only 25 dollars. You have admin control and can allow/disallow public uploading. A lot of other nice nifty features. I was thinking of it so my members can post funny flash and mpeg movies...
http://www.celerondude.com/ |
That mey help the poster of this topic but not me :( |
|
Back to top |
|
|
|