kvarnerexpress
Sep 19 2005, 10:07 PM
i have never tried to have files uploaded and i am still not able to do so. here is the codes that i am using right out of the php manual and it still isnt working. i have also listed the warnings/errors listed on the resulting page. my permissions are set to 777 also. i have a folder set up on my server as "uploads". i am however not sure if i have a default temp folder on my server. can anyone help me figure out what i am not doing correctly or what my next step is? this is the form that i am using: html Code: CODE <form enctype="multipart/form-data" action="upload.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="userfile" type="file" /> <input type="submit" value="Upload File" /> </form> this is the php page "upload.php" php Code: CODE # # <?php # $uploadDir = '/uploads/'; # $uploadFile = $uploadDir . $_FILES['userfile']['name']; # print "<pre>"; # if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)) # { # print "File is valid, and was successfully uploaded. "; # print "Here's some more debugging info:\n"; # print_r($_FILES); # } # else # { # print "Possible file upload attack! Here's some debugging info:\n"; # print_r($_FILES); # } # print "</pre>"; #
this is the resulting error: Code: CODE Warning: move_uploaded_file(/uploads/golf.jpg): failed to open stream: No such file or directory in /home/jesokcc/public_html/upload.php on line 5
Warning: move_uploaded_file(): Unable to move '/tmp/php72OLgu' to '/uploads/golf.jpg' in /home/jesokcc/public_html/upload.php on line 5 Possible file upload attack! Here's some debugging info: Array ( [userfile] => Array ( [name] => golf.jpg [type] => image/pjpeg [tmp_name] => /tmp/php72OLgu [error] => 0 [size] => 9802 )
) Thanks,kvarnerexpress
Comment/Reply (w/o sign-up)
arboc7
Sep 20 2005, 12:26 AM
It looks like your code is valid and should work. On what kind of server are you running this script? (i.e., Linux, Windows, et cetera) You may simply have a permissions problem that either you or the server administrator needs to change. That's all of which I can think! Hope this helps!!
Comment/Reply (w/o sign-up)
Spectre
Sep 26 2005, 05:23 AM
Try changing $uploadDir = '/uploads/'; to $uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/'; As it is now, PHP will try and copy the uploaded file into the '/uploads' directory on the root of the server - not the root of your site, which is probably something like '/www/username/public_html/'.
Comment/Reply (w/o sign-up)
sonesay
Nov 24 2008, 04:17 AM
I'm also just trying out file uploads myself. Having some issues though. using the example from php website: http://nz2.php.net/features.file-uploadbut I'm getting this error with some missing values: CODE Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => 01aa.jpg [type] => [tmp_name] => [error] => 6 [size] => 0 )
) any help appreciated ^^ CODE <html> <head> <title></title> </head> <body> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="uploader.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form>
</body> </html> CODE <?php // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES.
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/'; ; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>'; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; }
echo 'Here is some more debugging info:'; print_r($_FILES);
print "</pre>";
?>
Comment/Reply (w/o sign-up)
jmark
Nov 24 2008, 09:57 AM
have you made the folder uploads to the destination file?
Comment/Reply (w/o sign-up)
sonesay
Nov 24 2008, 10:01 AM
Yeah I had a error code of 6. I looked at the php.net documentation and found out it was because I was missing a temp location setting in php.ini so I set that and it works. Changed the code a bit but its working now. I just need to find ways to secure and check files being uploaded.
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : file, uploading, issues
- Php - Fetching Random Line From A Text File
and displaying it using AJAX/iframe (0)
Linux/ Apache /mod_rewrite Issue
Error when accessing a file (4) running on Ubuntu 8.04 with an XAMPP - php5.2.5, Apache 2., etc Getting this error when I try to
access an sNews CMS which requires mod_rewrite and is installed locally: QUOTE Apache/2.2.8
(Unix) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8e PHP/5.2.5 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2
Perl/v5.10.0 configured -- resuming normal operations /opt/lampp/htdocs/jim/snews/.htaccess:
RewriteBase: argument is not a valid URL /opt/lampp/htdocs/jim/snews/.htaccess: RewriteBase:
argument is not a valid URL Using this link: http://localhost/jim/snews/snews16_ema....
Php Configuration File
"config.php" (18) I did create this topic mainly because I want to know everything about that configuration file. I
will post other replies if I want to know more depending on your experience. Is this code correct
for that file: CODE $host="localhost"; $dbname="XXX"; $dbuser="XXX"; $dbpass="XXX";
$connection=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname)
or die(mysql_error()); ?> Add your suggestions or improve it.....
Need Some Help In File Browser
listing all sub folders and files in them. (8) Hey I want to create a very simple file browser, so that, it reads all the sub-folders which are
places in a directory, and the files inside the sub-folders (It reads only files inside sub-folders
and list them in simply. ) Also, it creates a directory (any name) inside each sub folder. My
Following code reads on the files inside the main directory, it does not read the files inside the
sub-folders.. I appreciate any help. CODE $path = "./"; $dir_handle = @opendir($path) or
die("Unable to open $path"); while ($file = readdir($dir_handle)) { if($file == "." || $fil....
Updating Php File Through A Web Form
(5) Hello, i'm not sure if this can be done with php or not but what i need is a way to make an php
file that have an html form on it and it will take the info you put in to that form and write it to
an existing php file, for example: if i have the file news.php and the file news_update.php. if you
went to news_update.php you would get an form with a text area for you to write a new addition for
the news.php file and when you hit submit it will add what you typed in the form to the file
news.php. If this is going to be a big code or a hard one to make but some one think....
Php Sessions And Post Variables Issues
My script dosent seem to work as intended (1) You can test it out for yourself at http://sonesay.trap17.com/application.php I've been
working on this page locally and it seems to be working fine but when I upload it to my trap17
account the post variables dont get saved properly. Fill in some fields and submit it, the form
will come up as a empty field yet when you resubmit it without any modifications and the data you
entered in orginally will now magically appear, resubmit it again and it will be gone. This is
really annoying as I have no clue why it would be doing this when it seems to work fine locally.....
File Checker-how To Check File Whith Html Through Html?
(2) edit:sorry for the mistake it is php not html and its with not whith my code checking script= CODE
$file = '$CHECK'; if (file_exists($file)) { echo "The file $filename exists"; } else
{ echo "The file $filename does not exist"; } ?> my question is how to check the file whith
html example:on a page a text box is provided and a button the user writes a file name (or website)
the user clicks on the submit button then it checks and show it (with the code above) i got the
code CODE $filename=$_POST ; if (file_exists($filename)) { echo "The....
Php And Flash Image Gallery
Need some help in creating or editing an xml file while viewing some o (5) Hello there and thanks for the helping hand you are offering. PHP newbie here! /ph34r.gif"
style="vertical-align:middle" emoid=":ph34r:" border="0" alt="ph34r.gif" /> So here is my problem:
On my website I have a flash image gallery.The way the gallery works is by uploading pictures in a
folder and editing? an xml file.(pics.xml) where it adds the following code when you upload a
picture: CODE etc... Now I have users that upload products they sell on the
website or they advertise their business(hotels, jewellers, car resellers,...) So for eve....
No File Extension
(3) On MediaWiki, the URL of the content is http://YOURWIKI.com/index.php/Blah Is it possible to
create a page or two that doesn't have a file extension? If so, how is it done?....
Need Help Uploading Php
(8) where can i upload php file and use it? im using this free webs the trap17 i want to use php like
a website....
File Upload
File upload (1) I need to add a facility on my customer's website so his clients can send him jobs, typically
5mb - 50mb. I've looked around the web and researched this, and tried a few tests (failed), but
my brain's beginning to hurt. Could someone please tell me the best way to go about this,
please. The site is done in Flash, but I'm sure a link to an html page would be ok if necessary.....
<?php ?> Unique Visitors Script
Flat file unique visitors script (no sessions) (2) This is really simple script. Well at least this part is, but it could be extendable. Only problem
is that it's not really for massive websites with hundread of visitors a day, but rather for
small ones. But it is a good script to figure out how to make a visitor counter script. Anyway
here's the snippet. CODE function getVisits($variable) { $visits = array(); if
($handle = opendir('stats/')) { while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { array_push($visits, $file); } ....
[php]simple Flat File Text Manipulator
Example on how to use forms to write to files in PHP (3) I made a simple flat file text editor, that can show you probably how simple it is to use forms with
php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php
is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs
are. Here's the file with comments. I think that HTML really doesn't need some more
explaining. CODE Title: Text: if (@$_POST =="" || @$_POST
==""){ echo "Enter text to save!"; } else { //this is path to file $filena....
Edit .txt File In Ftp Via Webpage
file on external ftp (2) Right Im new here and stuggling with a problem im having. I've currently got a Login Script to
login to a external ftp and it displays the folders contents, however i need it so it echos a
specific file (coursedata.cfg) into a formarea which you can then edit the file and when u click
save it overwrites the file with the new one. Im really quiet getting annoyed with it xD as
everything i do ends up trying to include the file from the webserver the script is hosted on and
not the external ftp source. thanks Full Code Bellow Simple FTP Manager body { fon....
Php Help Needed Including File In A Page.
(2) i'm a noob in php programming, i can understand and modify php programs, but i dont know to
write on my own. So please somebody who is well versed in php help me. My need is, I'm
currently builiding a knowledge base website , i've my own design for the website, check here,
http://laschatz.info/kzone/ Each page in the left hand site has a tree navigation of all the
topics available. Since this information must be same in all the pages, presently I need to change
all the pages after adding a new category. Could you please help me in such a way that I can ad....
Help Php: How To Load String From Text File (solved)
Loading string from text file when you click on your link (9) I learned the way to load other files with the code posted on this forum. Now i wanted to try
something for my side menu. I am calling this a string, --> $tekst , maybe it's called
something else i'm not sure Now let's say i have a file called details.txt In that file i
would like to have something like this $detailsaboutphp1 = ("details details details 1");
$detailsaboutphp2 = ("details details details and even more details 2"); How to make a code that
loads those $strings on click of a mouse. When we tried to load external file we used this:
....
Uploading A Photo...
(3) hi everyones
I'm trying to have a photo gallery. I want to have the possibility to upload a photo. Looking on
the web I tryed out to do so with php. But it is not working. I get this error...
....
Help Needed With Directory/file Listing Code Infinite Loop
Made an infinite loop but why is this so? (5) Hi all ive got a small and simple (for the moment atleast /unsure.gif"
style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> )file and directory
listing script in php as follows CODE $dir = "."; $num = 0; $file = scandir($dir); while($file
= scandir($dir)){ echo $file ; echo " "; $num = $num + 1; }; the concept is
simple enough, the directory to start with is the current one, so scan this directory and while we
have a result do a loop to echo the file/directories found, incriment the array number by one so we
get the....
Sql Selection Issues
(1) CODE CREATE TABLE pbm_album ( id TINYINT(8) AUTO_INCREMENT, parent_id TINYINT(8)
pbm_name VARCHAR(100), pbm_desc VARCHAR(150), pbm_order TINYINT(8), pbm_image
varchar(100), pbm_cat_id TINYINT(8), pbm_create_date int NOT NULL, FOREIGN KEY
pbm_cat_id REFERENCES pbm_catalog(id), PRIMARY KEY(id) ) CREATE TABLE pbm_photo ( id
TINYINT(8) AUTO_INCREMENT, pbm_name varchar(20) NOT NULL, pbm_title varchar(60) NULL,
pbm_album_id TINYINT(8) NOT NULL, pbm_create_date int NOT NULL, FOREIGN KEY pbm_album_id
REFERENCE....
Display Random File In A Directory
how to display a random file from a set directory. (9) hi, could someone please help me with this? I have some files in a directory and i want to know how
i can randomly display link/s to one or more of the files in my directory for download. But it must
not at any time display index.php which is also in the directory with the downloads. Thanks in
advance for any help given /unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0"
alt="unsure.gif" />....
File Format Unknown! (wap)
someone PLEASE HELP! (6) hi people :-) listen please can someone help me find the error in this wapsite page, its driving me
nuts! It works fine on some phones but not on others (giving a file format unknown error) and im
having serious problems finding the error but i bet its something stupid/simple. CODE include
("config.php"); include ("core.php"); header("Content-type: text/vnd.wap.wml");
header("Cache-Control: nostore, nocache, mustrevalidate"); print " "; echo " "; ?> $uid =
$_POST ; $pwd = $_POST ; $cpw = $_POST ; connectdb(); echo " "; $ipr = getip(); $uip =
explode(....
File In Database
Question.thanks (1) Hi all i write this code i want when you see download.php (this code) my file goes for download for
user sorry my english is not very good its a file database project for my university but when i
browse this code my soruce file (.zip) echo in my page and dont goes for download my next querstion
about safe mode i saw (php.net and zend) when safemode is on file databaseing and header() is not
working . is it true ? if is it true i save my file at hosting and no (database) i want write
standard script . plz help me thanks more and more CODE include("config.php"); $kind....
Php Writes Into Txt File
a question (8) QUOTE $fp=fopen("test.txt","a"); fputs($fp,"ok"); ?> The above method is only to add "ok"
at the end (DO NOT write on a new line) I want to know... How to add data on a new line and at the
end of txt file??! thx~....
File String Delete?
(2) Say i have a file file.txt... Can someone give me an example of how to delete a string from this
file ie.. The file contains: wappy::sucks::at::php --- i want to delete sucks::....
Include File.php?id=something
using the include() function (13) Well, I am making a full CMS system for my site, and want to make the index.php file to include the
view.php?id=1 file. I tried with this code, but it didn't work: CODE This is the error
I get: CODE Warning: main(view.php?id=1) : failed to open stream: Invalid argument in
C:\server\xampp\htdocs\test\index.php on line 1 Warning: main() : Failed opening
'view.php?id=1' for inclusion (include_path='.;C:\server\xampp\php\pear\') in
C:\server\xampp\htdocs\test\index.php on line 1 So what can I do?....
I Need Help With File Edit In Php
with ftp (6) Currently i have CODE if($_POST =="" or $_POST =="" or $_POST =="" or $_POST =="" or
!isset($_POST )){ print(' '); print('FTP username '); print('FTP
password '); print('FTP Host '); print('FTP Root Directory ');
print(' '); print(' '); }else{ $ftp_server = $_POST ; $ftp_user = $_POST ;
$ftp_pass = $_POST ; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to
$ftp_server please refresh and do not click retry"); // try to login if (@ftp_login($conn_id,
$ftp_user, $ftp_pass)....
Error When Using file_put_contents()
failed to call to undefined function (5) Hey all, I decided to write a script which writes some text to a file, but I have a problem when I
execute the script, I get a fatal error: QUOTE(homepage) Fatal error : Call to undefined
function: file_put_contents() in /home/cmatcme/public_html/afile.php on line 55 This is the
code I'm using to write the file: $ipfnsdoc = "/home/cmatcme/public_html/afolder/afile.txt";
if (!is_readable($ipfnsdoc)) { echo "File cannot be read"; $stopload = 1; } if
(!is_writable($ipfnsdoc)) { echo " \nFile cannot be written to"; $stoploa....
Script: Php Jukebox
A one file script! (6) This scripts is so simple, you dont need to edit ANY of it! All you have to do is make a folder
called 'songs' and put some audio files in it. Here is the whole page, I named it index.php
and put it in a folder called 'music': CODE PHP jukebox ©2005 Craig lloyd.
All rights reserved. Visit cragllo.com for more scripts --> /** * ©2005 Craig lloyd. All rights
reserved. * * Mod Title: Simple PHP Jukebox * Author: Craig Lloyd * Author
Email: cragllo@cragllo.com * Author Homepage: http://www.cragllo.com/ * Des....
Getting List Of Directories And Files Using Php
PHP Function for Directory and File List (6) is there a php function that lists the content of some folder.... example: /New folder new.txt
left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
style='vertical-align:middle' alt='rolleyes.gif' /> ....
Pages In 1 File
?? (10) I know its possible to put many pages inside 1 file. But how? Lets say you have a guestbook with
different pages for signing and viewing. How to make so those pages are in 1 file? /huh.gif"
style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" />....
Looking for file, uploading, issues
|
Searching Video's for file, uploading, issues
See Also,
|
advertisement
|
|