ladybugmom:
I received an email back from the UPLOAD-POINT in regards to selecting only certain file extensions to be uploaded and this was his reply. I have not used it yet, but wanted to pass it on to those who wanted to used it.
In index.php after line 306 is: // Path from domain name to upload
directory and line 315 is: // Redirect to upload page.
Replace the current code between these lines with this:
$file_ext = basename($_FILES['ftp_file']['name']);
$ext = substr($file_ext, strrpos($file_ext, '.') + 1);
$upload_dir = ($_SERVER['DOCUMENT_ROOT'] . "/$fileupload_dir_name/");
$target_path = $upload_dir . basename( $_FILES['ftp_file']['name']);
if (($ext == "ai") || ($ext == "eps") || ($ext == "psd") || ($ext ==
"pdf") || ($ext == "png") || ($ext == "gif") || ($ext == "tif") || ($ext
== "rar") || ($ext == "7z") || ($ext == "zip")) {
if (move_uploaded_file($_FILES['ftp_file']['tmp_name'], $target_path)) {
chmod($upload_dir . basename( $_FILES['ftp_file']['name']), 0644);
echo $p."$l_upload13 ". basename( $_FILES['ftp_file']['name']). "$p2";
} else {
echo $p."$l_upload14 ". basename( $_FILES['ftp_file']['name']). "$p2";
}
} else {
echo $p."$l_upload14 ". basename( $_FILES['ftp_file']['name']). "$p2";
}
The new line 311:
if (($ext == "ai") || ($ext == "eps") || ($ext == "psd") || ($ext ==
"pdf") || ($ext == "png") || ($ext == "gif") || ($ext == "tif") || ($ext
== "rar") || ($ext == "7z") || ($ext == "zip")) {
is where you can add or remove file types. If you just want .jpg files
then it should be:
if (($ext == "jpg")) {
This form's working great so far (many thanks to ladybugmom!). The only problem is when I tried limiting the type of file uploads.
I did the above instructions. Here's how my code turned out:
// Upload
// Path from domain name to upload directory and line
$file_ext = basename($_FILES['ftp_file']['name']);
$ext = substr($file_ext, strrpos($file_ext, '.') + 1);
$upload_dir = ($_SERVER['DOCUMENT_ROOT'] . "/$fileupload_dir_name/");
$target_path = $upload_dir . basename( $_FILES['ftp_file']['name']);
if (($ext == "jpg") || ($ext == "jpeg") || ($ext == "psd") || ($ext ==
"pdf") || ($ext == "png") || ($ext == "gif") || ($ext == "tif") || ($ext
== "cdr") || ($ext == "eps") || ($ext == "tiff") || ($ext == "bmp") || ($ext == "ai")) {
if (move_uploaded_file($_FILES['ftp_file']['tmp_name'], $target_path)) {
chmod($upload_dir . basename( $_FILES['ftp_file']['name']), 0644);
echo $p."$l_upload13 ". basename( $_FILES['ftp_file']['name']). "$p2";
} else {
echo $p."$l_upload14 ". basename( $_FILES['ftp_file']['name']). "$p2";
}
} else {
echo $p."$l_upload14 ". basename( $_FILES['ftp_file']['name']). "$p2";
}
// Redirect to upload page.
But when I finished uploading an image, this message appeared briefly:
Warning: basename() expects parameter 1 to be string, array given in /home/ncom2/public_html/imuniforms.com/upload/index.php on line 307
Warning: basename() expects parameter 1 to be string, array given in /home/ncom2/public_html/imuniforms.com/upload/index.php on line 310
Warning: basename() expects parameter 1 to be string, array given in /home/ncom2/public_html/imuniforms.com/upload/index.php on line 321
There was a problem uploading
Automatically redirecting to the Upload-Page
-----------------------------------------------
Uploading then failed. I have about zero knowledge of php. Can somebody enlighten me?
It would be much appreciated!
Grateful zencarter