hai pals,
iam jaison justus from india. i have a problem in uploading files using a given path.
the code snip is:
<?php
$image = '/User/test/picture/test.png';
$path = 'art/' + basename($image);
# i need to upload this picture from client machine to my server machine.
# how can i do it
# i used move_uploaded_file() function
move_uploaded_file($image,$path);
# but its not not working how can i do it
# please help me
?>
file upload problem please help
Moderator: General Moderators
-
jaisonjustus
- Forum Newbie
- Posts: 3
- Joined: Thu Nov 05, 2009 10:52 pm
Re: file upload problem please help
Hi, jaison justus
I think you need the following code though your need is not clear!
Try this code:
// HTML Code Client side
<form name="" method="POST" enctype="multipart/form-data">
select file:<input type="file" name="image">
<input type=submit name="addfiles" value="Upload File">
</form>
I think you need the following code though your need is not clear!
Try this code:
Code: Select all
<?
// File size
$_FILESIZE="2000000";
if(isset($_POST['addfiles']))
{
$oldfile = $_FILES['image']['name'];
$uploadfile = $_FILES['image']['name'];
$path = 'art/' + basename($image); // remeber chmod 777 in this dir
if ($_FILES['image']['size']>$_FILESIZE)
{
$error.="Too big!!";
}
if (empty($error))
{
move_uploaded_file($_FILES['image']['tmp_name'],"".$path."/$uploadfile");
$_OK="uploaded";
}
?>
<form name="" method="POST" enctype="multipart/form-data">
select file:<input type="file" name="image">
<input type=submit name="addfiles" value="Upload File">
</form>
-
sureshmaharana
- Forum Commoner
- Posts: 30
- Joined: Thu Jul 03, 2008 4:20 am
- Contact:
Re: file upload problem please help
Use this :
$path = realpath(dirname(__FILE__) . '/../') . "/art/".basename($image);
$path = realpath(dirname(__FILE__) . '/../') . "/art/".basename($image);
-
jaisonjustus
- Forum Newbie
- Posts: 3
- Joined: Thu Nov 05, 2009 10:52 pm
Re: file upload problem please help
hai friends,
thanx for the reply...
pal actual i have a file path which is hard coded
which is
$file = User/test/test.png';
and i need to move it to a a folder in the server name art;
$path = 'art/';
how can i do it with out using post method..
so the problem is, i have two variable $path and $file having upload directory path in the server and other is the file actual path of a picture.
and i need to upload the picture to the server. no post actions.
the file upload.php
<?php
$file = 'User/test/test.png';
$path = 'art/';
# please fill up the upload code here using
# the above variables. no post action.
# hard coded details only
?>
thanx for the reply...
pal actual i have a file path which is hard coded
which is
$file = User/test/test.png';
and i need to move it to a a folder in the server name art;
$path = 'art/';
how can i do it with out using post method..
so the problem is, i have two variable $path and $file having upload directory path in the server and other is the file actual path of a picture.
and i need to upload the picture to the server. no post actions.
the file upload.php
<?php
$file = 'User/test/test.png';
$path = 'art/';
# please fill up the upload code here using
# the above variables. no post action.
# hard coded details only
?>