Uploading files via php to var/lib
Moderator: General Moderators
-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Uploading files via php to var/lib
I have written a script to upload to the path var/lib/asterisk/sounds/ but it will not read the uploader.php via the path i provided ion the action, how can i resolve this
code:
<form enctype="multipart/form-data" action="var/lib/asterisk/sounds/uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
code:
<form enctype="multipart/form-data" action="var/lib/asterisk/sounds/uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Uploading files via php to var/lib
Are you sure you didn't miss the leading /?
Why did you put your script into Asterisk's subdirectory for sound files?
Usually this directory is owned by asterisk user and you don't have permissions to write there anything.
Why did you put your script into Asterisk's subdirectory for sound files?
Usually this directory is owned by asterisk user and you don't have permissions to write there anything.
-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Re: Uploading files via php to var/lib
All I need is a way to upload the sound wav to the asterisk sounds folder via php, any help would be great.
-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Re: Uploading files via php to var/lib
I even tried
/var/lib/asterisk/sounds/uploader.php
and it shows the ip /var/lib/asterisk/sounds/uploader.php in the address bar in the browser
gives me 404
/var/lib/asterisk/sounds/uploader.php
and it shows the ip /var/lib/asterisk/sounds/uploader.php in the address bar in the browser
gives me 404
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Uploading files via php to var/lib
Your uploader.php must be located in any www directory.
Show the code of your uploader.php
Show the code of your uploader.php
-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Re: Uploading files via php to var/lib
<?php
$target_path = "/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$target_path = "/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Uploading files via php to var/lib
Code: Select all
$target_path = "/";Code: Select all
$target_path = "/var/lib/asterisk/sounds/";-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Re: Uploading files via php to var/lib
chmod var/lib/asterisk/sounds to 777
and set target to what you suggested and get:
There was an error uploading the file, please try again!
and set target to what you suggested and get:
There was an error uploading the file, please try again!
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Uploading files via php to var/lib
BTW remove basename()
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Uploading files via php to var/lib
Add as following
Code: Select all
...
} else{
echo "There was an error uploading the file, please try again!\n";
echo "Error: " . $_FILES['uploadedfile']['error'] . "\n";
}
Last edited by DigitalMind on Thu Sep 30, 2010 10:54 am, edited 1 time in total.
-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Re: Uploading files via php to var/lib
removed baseline data
<?php
$target_path = "/var/lib/asterisk/sounds/";
$target_path = $target_path . ;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". .
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
shows nothing
<?php
$target_path = "/var/lib/asterisk/sounds/";
$target_path = $target_path . ;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". .
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
shows nothing
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Uploading files via php to var/lib
See my post above.
P.S. Use
P.S. Use
Code: Select all
for your code
P.P.S. I'll be back after English lesson (in a few hours) :)-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Re: Uploading files via php to var/lib
There was an error uploading the file, please try again! Error: 2
but i had to add baseline back to get that error
but i had to add baseline back to get that error
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: Uploading files via php to var/lib
2 = UPLOAD_ERR_FROM_SIZE
hint: see MAX_FILE_SIZE
hint: see MAX_FILE_SIZE
-
chrisatnetronix
- Forum Newbie
- Posts: 16
- Joined: Mon Jul 19, 2010 8:13 pm
Re: Uploading files via php to var/lib
works, your the man, i am retarded:)